Expanding an object to set attributes in Jade

大兔子大兔子 提交于 2019-12-05 04:20:34

Since you are a part of this issue on GitHub, you probably already know the answer. But, for anyone else, here is the answer:

Jade:

input.foo(name=name value=value)&attributes(attrs)

Pass this data to your render function:

{
    name: 'username',
    value: 'bob',
    attrs: {
        maxlength: 16
    }
}

Output:

<input name="username" value="bob" class="foo" maxlength="16"/>

You need to pass a object name or use the keyword 'global' like this:

partial('myview', { { 
    name:'username',
    value:'bob',
    attributes: {
        maxlength: 16
    }
}, as: global });

otherwise you need to give your object a name and access them through that scope.

Check out the docs

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