Posted Tue, 29 Jan 2013 09:09:26 +0100 in reply to
Matej Nanut
Reply
Am 28.01.2013 22:45, schrieb Matej Nanut:
Hello!
I found this in the Jade documentation, but can't get it to work here.
Example:
- if (autofocus)
input(type="text", autofocus="#{autofocus ? "autofocus" : null}")
The autofocus element should disappear if autofocus == false, but it leaves it there with an empty
string.
If this isn't implemented, how can I get optional attributes without exponentially blowing up if
conditions?
Thanks, Matej
A similar way to do this has just been implemented in the latest version. If autofocus
is a
boolean value then this should work:
input(type="text", autofocus=autofocus)
Arbitrary D-expressions are now supported for attribute values. It doesn't work inside of a string
interpolation or using a ternary operator, though, because of D's statically typed nature.