I need to create div's with class pixel-1
,pixel-2
... pixel-n
and my question is how to achieve it with pug
. I tried this:
- for (var x = 1; x < 13; x++)
.pixel-x=x
but it's generate css like this:
<div class="pixel-x">1</div>
<div class="pixel-x">2</div>
<div class="pixel-x">3</div>
...
The names of the variables in your Pug file become siteColors and siteNames . To set the entirety of an HTML element equal to a variable, use the equals operator = to do so. If your variable needs to be embedded inline, use bracket syntax #{} to do so.
You could do it like this:
- for (var x = 1; x < 13; x++)
div(class='pixel-' + x)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With