问题
In older versions of jade you could pass the attributes of a mixin on to a block within it like so:
mixin a
a(attributes=attributes)
block
+a(href='foo')
| Bar
however this now results in
<a attributes="[object Object]">Bar</a>
instead of
<a attributes="foo">Bar</a>
Other failed attempts to get this working are shown below. Does anyone know what the new syntax is?
Attempt 2
mixin a
a(attributes)
block
+a(href='foo')
| Bar
Result:
<a attributes="attributes">Bar</a>
Attempt 3
mixin a
a()(attributes)
block
+a(href='foo')
| Bar
Result:
<a attributes="attributes">Bar</a>
Attempt 4
mixin a
a()(attributes=attributes)
block
+a(href='foo')
| Bar
Result:
<a attributes="[object Object]">Bar</a>
回答1:
It now looks like you use
mixin a
a&attributes(attributes)
block
+a(href='foo')
| Bar
and https://github.com/visionmedia/jade/issues/1294 serves as the documentation.
来源:https://stackoverflow.com/questions/24599006/passing-attributes-in-a-jade-mixin