posthtml-expressions
posthtml-expressions copied to clipboard
Set attributes via locals
It seem that it's not possible to set attributes via locals, but only values.
So it's not possible to set dynamically the "selected" or "disabled" attribute to a select or input tag.
It's that correct?
I tried several things but seem not working.
Would be possible to set something like:
<select>
<option :selected="{{ selected }}">option 1</option>
<option>option 2</option>
</select>
Notice the ":" before attribute. When this and when {{ selected }} value is undefined, NULL and/or false, then :selected attribute get removed from tag.
Maybe would better a custom plugin that loop over tag with such attributes and remove attribute when condition match?
What do you think?
I made a small plugin for handle this, it's pretty easy. Will publish it soon.