简体   繁体   English

玉模板:属性循环?

[英]Jade templating : loop in attributes?

I have a javascript object in my jade view like this : 我在我的玉视图中有一个javascript对象,如下所示:

element = {
    name: 'createdAt',
    type: 'text',
    attrs: {
        class: 'date',
        type: 'text',
        placeholder: 'Created at'
    }
}

I would like generate attributes on an input tag, trying something like this 我想在输入标签上生成属性,尝试这样的事情

input(
   each k, v in element.attrs
       k= v  
)

Of course this doesn't work, I also tried some inline code but without success. 当然这不起作用,我也尝试了一些内联代码,但没有成功。 Do you have any idea to help me ? 你有什么想法帮助我吗?

From documentation: 来自文档:

Pronounced "and attributes", the &attributes syntax can be used to explode an object into attributes of an element. 发音为“and attributes”,&attributes语法可用于将对象分解为元素的属性。

div#foo(data-bar="foo")&attributes({'data-foo': 'bar'})

http://jade-lang.com/reference/attributes/#and-attributes http://jade-lang.com/reference/attributes/#and-attributes

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM