A
A
Adex2017-09-06 21:12:31
Pug
Adex, 2017-09-06 21:12:31

PUG how to set variable in class name?

I didn’t find a pug on the site (mb searched badly), how to add a variable to the class name in the mixin? For example, to
.b-content-img-
assign numbers to k, i.e. .b-content-img-1 etc?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
O
Oleg, 2017-09-06
@Adex

img(class=`b-content-img-${number}`)

K
Khatam Soyunov, 2019-01-30
@hattam

If you need to add the value of a variable to the class, then do this:

- var class_name = 'my_class'
div(class="" +class_name )

Compiles:
<div class="my_class">

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question