2013-07-23 48 views
1

使用Polymer Project標記,<element><polymer-element>標記採用名爲attributes的屬性來發布自定義元素(1)中的內容。稱爲「屬性」的Jade HTML屬性

這會導致翡翠問題,因爲#617attributes作爲屬性名稱被專門處理。 Jade有沒有解決這個問題的方法?

回答

1

只要把「\」的屬性,屬性之前,像這樣

polymer-element(\attributes='foo bar') 

這只是一個猜測,但它的工作。在文檔中找不到任何參考。

所以認爲它是一種工作。

+0

這不再起作用,不再需要。 – ForbesLindesay

1

我不知道這是否有助於您的特定情況,但請注意,您可以在原型中使用名爲publish的對象屬性來代替<polymer-element>上的attributes屬性。

E.g.

<polymer-element attributes='foo bar'...>... 

相當於

<polymer-element...>... 
    <script> 
    Polymer(..., { 
     publish: { 
     foo: null, 
     bar: null 
     } 
    } 

這樣,你應該能夠,至少,寫你自己的元素不會撞上玉語法。

+0

是的,這是解決辦法我目前正在使用。鑑於Polymer中關於首選「屬性」語法的註釋以及我自己的審美偏好,我更喜歡基於標記的解決方案。 –

1

只是爲了保持這個答案了最新,attributes是沒有更多的玉保留:)。

2

最近更新玉(V1.0.0及更高版本)attributes後不再是特殊的套管。因此,你可以這樣寫:

polymer-element(attributes='foo bar') 

結果:

<polymer-element attributes="foo bar"></polymer-element> 

如果你想嘗試一下在你的瀏覽器,您可以這樣做:http://jade-lang.com/demo/