I'm trying to create multiple divs in pug this is the code I have:
- for(var x = 0;x < 3;x++)
.background-line.line-x
How do I use the variable "x"?
Thank you in advance.
Your structure is setup correct, but you need to follow indentations rules for PUG.
The line .background-line.line-x
has to be nested under your for
loop. You can see in the pen below:
https://codepen.io/mdiggss/pen/eGaEBO
As for the variable x
, this is used as your counter for the for
loop and it will iterate as long as x
is < 3
- Your sample will produce 3 divs each with the classes you specified.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.