Passing attributes in a jade mixin

╄→尐↘猪︶ㄣ 提交于 2019-12-11 02:48:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!