Answer the question
In order to leave comments, you need to log in
How to add another loop function to PUG?
I made a loop for the article
tag and added an each function for the images, but I don't know how to add the same function for the product name and price in the same loop so that they are different from the images.
Unfortunately, the official PUG documentation did not help much in this matter, I would be grateful if you could help.
.product--production-wrapper
- for (var i = 0; i < 6; i++)
- var imagePath = ('assets/img/product-image/')
each picture, bedFurniture in ['bed-1.jpg', 'bed-2.jpg', 'bed-3.jpg', 'bed-4.jpg', 'bed-5.jpg', 'bed-6.jpg']
article.bed.card
.product--image
a(href="#"): img(src= imagePath + picture)
.product--desc-wrapper
.product--name-href
h5 Название Продукта
a(href="#") Кровати
a(href="#").price Цена $2999
Answer the question
In order to leave comments, you need to log in
.product--production-wrapper
each item in [ {image: 'bed-1.jpg', price: '1999', name: 'Название продукта 1'}, {image: 'bed-2.jpg', price: '345', name: 'Название продукта 2'}, {image: 'bed-3.jpg', price: '2329', name: 'Название продукта 3'} ]
article.bed.card
.product--image
a(href="#"): img(src=`assets/img/product-image/${item.image}`)
.product--desc-wrapper
.product--name-href
h5= item.name
a(href="#") Кровати
a(href="#").price= item.price
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question