在玉混合中传递属性 [英] Passing attributes in a jade mixin

查看:38
本文介绍了在玉混合中传递属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在旧版本的 jade 中,您可以将 mixin 的属性传递给其中的块,如下所示:

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

但是现在结果

<a attributes="[object Object]">Bar</a>

代替

<a attributes="foo">Bar</a>

其他失败的尝试如下所示.有谁知道新语法是什么?

Other failed attempts to get this working are shown below. Does anyone know what the new syntax is?

尝试 2

mixin a
    a(attributes)
        block

+a(href='foo')
    | Bar

结果:

<a attributes="attributes">Bar</a>

尝试 3

mixin a
    a()(attributes)
        block

+a(href='foo')
    | Bar

结果:

<a attributes="attributes">Bar</a>

尝试 4

mixin a
    a()(attributes=attributes)
        block

+a(href='foo')
    | Bar

结果:

<a attributes="[object Object]">Bar</a>

推荐答案

现在看起来你使用了

mixin a
    a&attributes(attributes)
        block

+a(href='foo')
    | Bar

https://github.com/visionmedia/jade/issues/1294作为文档.

这篇关于在玉混合中传递属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆