Answer the question
In order to leave comments, you need to log in
How to partially change attribute values in a loop in Pug?
Good evening!
I'm learning the syntax and features of Pug.
I came across the fact that you need to make 3 identical blocks, but with slightly different attribute values. And the first thought is naturally cycles. I began to write but something went wrong with me with him.
You need to do the following markup:
<div class="item">
<img src="/img/1.jpg" srcset="/img/[email protected] 2x">
</div>
<div class="item">
<img src="/img/2.jpg" srcset="/img/[email protected] 2x">
</div>
<div class="item">
<img src="/img/3.jpg" srcset="/img/[email protected] 2x">
</div>
each val in [1,2,3]
div.item
img(src='/img/#{val}.jpg' srcset='/img/#{val}@#{val}x.jpg 2x')
#{val}
, '/img/' + #{val} + '.jpg'
, '/img/' + val + '.jpg'
Answer the question
In order to leave comments, you need to log in
each val in [1,2,3]
div.item
img(src="/img/#{val}.jpg" srcset="/img/#{val}@2x.jpg 2x")
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question