A
A
Anastasia Dementieva2016-06-08 16:48:04
Pug
Anastasia Dementieva, 2016-06-08 16:48:04

Menu on jade, how to make it up?

- var categories = ["Мобильные телефоны","Планшеты","Навигаторы"]
- var categoricons = ['img/categories/icon1.png','img/categories/icon2.png','img/categories/icon3.png']
                 
  ul.categories
    each item in categories
    
    
      li.categories__item
        a(href="").categories__link
          span.categories__icon
            each item in categoricons                        
              img(src= "#{item}")
          span.categories__text= item
       .categories__count 85

Compiles:
<ul class="categories">
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon1.png"/><img src="img/categories/icon2.png"/><img src="img/categories/icon3.png"/></span><span class="categories__text">Мобильные телефоны</span></a></li>
  <div class="categories__count">85</div>
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon1.png"/><img src="img/categories/icon2.png"/><img src="img/categories/icon3.png"/></span><span class="categories__text">Планшеты</span></a></li>
  <div class="categories__count">85</div>
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon1.png"/><img src="img/categories/icon2.png"/><img src="img/categories/icon3.png"/></span><span class="categories__text">Навигаторы</span></a></li>
  <div class="categories__count">85</div>
</ul>

And you need:
<ul class="categories">
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon1.png"/></span><span class="categories__text">Мобильные телефоны</span></a></li>
  <div class="categories__count">85</div>
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon2.png"/></span><span class="categories__text">Планшеты</span></a></li>
  <div class="categories__count">85</div>
  <li class="categories__item"><a href="" class="categories__link"><span class="categories__icon"><img src="img/categories/icon3.png"/></span><span class="categories__text">Навигаторы</span></a></li>
  <div class="categories__count">85</div>
</ul>

Help, who knows, please =)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
Konstantin Kitmanov, 2016-06-08
@sguschenka

There is in the documentation :

each item, index in categories
    // ...
    img(src= "#{categoricons[index]}")

The nested loop is not needed.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question