2013-10-18 98 views
2

我想用Diazo replaceattributes規則替換一些CSS樣式,但到目前爲止我還沒有弄明白。Diazo - 替換css屬性

到目前爲止,我一直在使用重氮replacecopybeforeafter,爲css:contentcss:themecss:content-childrencss:theme-childrendrop規則成功。

我當前的標記是基於關閉Twitter的引導3.0如下:

<div class="container"> 
    <div class="row"> 
     <div id="content" class="col-md--8 well"> 
      <p>Plone content here</p> 
     </div> 
    </div> 
</div> 

使用drop規則我可以​​從我#content刪除類:

<drop attributes="class" css:theme="#theme"/> 

但我不能圖瞭解如何添加css類col-12col-12在我的主題中並不存在。我曾嘗試以下規則至今:

<replace attributes="class col-12" css:theme="#theme"/> 
<replace attributes="col-12" css:theme="#theme"/> 

我有一個copy治所在href鏈接從Plone的#portal-logo複製的例子:我覺得像我靠近

<copy attributes="href" css:content="#portal-logo" css:theme="#logo" /> 

,我需要的只是一個類似的例子。我一直在尋找Diazo文檔Basic syntax,但還沒有能夠找出這一個。

任何幫助,將不勝感激,如果我想出解決辦法之前,我得到迴應,我會更新我的問題

感謝。

+0

http://developer.plone.org/reference_manuals/external/diazo/recipes/adding-an-attribute/index.html有幫助嗎? – SteveM

回答

6

我通常使用此規則旭日電網 「映射」 到引導(2):

<replace content="//div[contains(@class,'cell')]/@class"> 
<xsl:attribute name="class"> 
<xsl:if test='contains(current(),"width-3:4")'>span9</xsl:if> 
<xsl:if test='contains(current(),"width-2:3")'>span8</xsl:if> 
<xsl:if test='contains(current(),"width-1:2")'>span6</xsl:if> 
<xsl:if test='contains(current(),"width-1:3")'>span4</xsl:if> 
<xsl:if test='contains(current(),"width-1:4")'>span3</xsl:if> 
<xsl:if test='contains(current(),"width-full")'>span12</xsl:if> 
</xsl:attribute> 
</replace> 

希望這有助於。

維託

0

我用的語法,如:

<replace content="//div[@class='row']"> 
    <xsl:attribute name="class"><xsl:value-of select="."/> col-12</xsl:attribute> 
</replace> 

到類添加到元素。

這個人應該添加類col-12(並保留現有row類)所有div s有row作爲內容中的類。