Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jade templating : loop in attributes?

I have a javascript object in my jade view like this :

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 ?

like image 512
harscoet Avatar asked Nov 06 '13 11:11

harscoet


1 Answers

From documentation:

Pronounced "and attributes", the &attributes syntax can be used to explode an object into attributes of an element.

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

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

like image 174
veidelis Avatar answered Oct 09 '22 05:10

veidelis