Answer the question
In order to leave comments, you need to log in
How to modify duplicate elements in html preprocessors?
Hello!
Example: when developing an online store, you need to put a stub in the form of a list of goods (literally three items in 10 rows). In order not to pile up the code, we use the html preprocessor and create a product card template. This template is output by a loop built into the preprocessor, since html tag structure for each product card is repeated, but the name, price, src of the image are different.
1) But how to output these differences through a loop?
2) What if there is a product card (let's say the second in the seventh row), which, in addition to the main html markup, has some labels in the form of NEW, TOP RATED, etc. - how to write this data into the output loop?
That is, roughly speaking, there is a card template:
<div class="item">
<div class="item_img">
<img src="path/to/img" alt="alt">
</div>
<h3 class="item_title">Product title</h3>
<p class="item_price">100$</p>
<p class="item_text">Lorem ipsum dolor sit amet.</p>
</div>
<div class="item">
<div class="item_img">
<img src="path/to/img" alt="alt">
<div class="item_label">NEW</div>
</div>
<h3 class="item_title">Product title</h3>
<p class="item_price">100$</p>
<p class="item_text">Lorem ipsum dolor sit amet.</p>
</div>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question