Conditionally include attribute in XML literal
Believe it or not, you can do it like this:
<input type='radio' name={funcName} value='true' checked={ if (cond) "checked" else null } />
This is one of the dark parts of Scala where null
actually gets used.
Just to make clear, it does exactly what you want: if cond
is false
, then input
will have no checked
attribute.