سؤال

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 ?

هل كانت مفيدة؟

المحلول

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

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top