Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable in class name - pug

Tags:

html

pug

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>
...
like image 273
Arkej Avatar asked Dec 15 '16 19:12

Arkej


People also ask

How do you declare a variable in a pug?

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.


1 Answers

You could do it like this:

- for (var x = 1; x < 13; x++)
  div(class='pixel-' + x)
like image 100
Punit Avatar answered Nov 15 '22 21:11

Punit