Jade HTML属性称为“属性”

时间:2013-07-23 19:26:38

标签: html pug polymer

使用Polymer Project标记时,<element><polymer-element>标记会使用名为attributes的属性在自定义元素(1)中发布内容。

这会导致jade出现问题,因为#617 attributes作为属性名称是专门处理的。在Jade有解决方法吗?

4 个答案:

答案 0 :(得分:2)

最近更新到jade(v1.0.0及更高版本)之后attributes不再是特殊套装。因此,你可以写:

polymer-element(attributes='foo bar')

结果:

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

如果您想在浏览器中试用,请访问:http://jade-lang.com/demo/

答案 1 :(得分:1)

我不知道这在您的特定情况下是否有帮助,但请注意您可以在原型中使用名为publish的对象属性代替attributes上的<polymer-element>属性}。

E.g。

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

相当于

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

这样你至少可以编写自己的元素,而不会碰到Jade语法。

答案 2 :(得分:1)

只需在attributes-attribute之前添加'\',就像这样

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

这只是一个猜测,但它确实有效。在文档中找不到任何关于此的参考。

因此,请将其视为一种解决方法。

答案 3 :(得分:1)

为了让这个答案保持最新状态,attributes在玉器中不再保留:)。

相关问题