pug - adding attribute in input field of Jade with javascript variable -
i want add attribute in input field local javascript variable as:
-var requiredfield = ('agent' == user.account_type.tolowercase()) ? 'required' : ''; input(type='text', name="name", placeholder="name", "#{requiredfield}")
but attribute #{requiredfield} in html. how can achieved?
i using jade. in advance
jade smart enough render required
attribute based off of boolean value: required=true
or required=false
.
input(type='text',required=true) input(type='text',required=false)
will render out as:
<input type='text' required /> <input type='text' />
so code sample, try instead:
-var isrequired = 'agent' == user.account_type.tolowercase(); input(type='text', name="name", placeholder="name", required=isrequired)
Comments
Post a Comment