I can\'t set a variable name in a class in jade:
.flag_#{ session.locale } #{ session.locale }
I have:
Here's another approach:
mixin formButton(text, type, extra_classes)
- var default_classes = 'btn btn-primary'
if extra_classes
- var classes = default_classes + ' ' + extra_classes
else
- var classes = default_classes
if type
button(class=classes type=type) !{text}
else
button(class=classes type="submit") !{text}
Example 1:
Usage:
+formButton('Text')
Result:
<button type="text" class="btn btn-primary" type="submit">Text</button>
Example 2:
Usage:
+formButton('Text', 'button')
Result:
<button type="text" class="btn btn-primary" type="button">Text</button>
Example 3:
Usage:
+formButton('Text', 'button', 'extra-class')
Result:
<button type="text" class="btn btn-primary extra-class" type="button">Text</button>
Try this (have not tested):
div(class="flag_#{ session.locale }") session.locale
As for pug@2.0.0-alpha3 works this way:
div(class="flag_" + session.locale) session.locale
You can also use conditional statements to do this like
if liked == true
span.like.active
else
span.like