How to add class in DIET template

Steven Schveighoffer via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Jun 23 10:15:42 PDT 2017


On 6/23/17 12:06 PM, Martin Tschierschke wrote:
> You can use the html syntax for the class parameter, the funny/nice 
> thing is, that mystr can be used directly without "#{}" around.
> 
> code(class=mystr) #{line}
> 
> works.

Yes, I just found out recently -- when you don't use quotes for an 
attribute value, it's treated as a D expression (and then interpolated).

If that D expression is of type bool, then the attribute is added or not 
based on the value of that bool. Good for things like checkboxes and 
'checked'.

-Steve


More information about the Digitalmars-d-learn mailing list