D
D
drtvader2017-01-27 10:02:49
Pug
drtvader, 2017-01-27 10:02:49

How to pass a condition to a JADE array?

Hey!
It was required to add an element in one place of an array. How can you do this with a condition?
Now there is a mixin:

+e('ul').list
            each item in data.items
                +e('li').item
                    +e.name
                        span #{item.title} 
                        if item.tooltip == true
                            +b('a')(title='' href='javascript:void(0);').help.--characteristic ?
                    +e.text #{item.text}

- data = {"items": [{"title": "WI-FI", "text": "Есть", "tooltip": "true"}, {"title": "Разрешение камеры", "text": "8 Мпикс"}, {"title": "Материал корпуса", "text": "Металл"}]}

 +characteristic-product('', ' ', data, '')

But doesn't work.
How can you do?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
drtvader, 2017-01-27
@drtvader

Found

+e('ul').list
            each item in data.items
                +e('li').item
                    +e.name
                        span #{item.title} 
                        if item.tooltip == true
                            +b('a')(title='' href='javascript:void(0);').help.--characteristic ?
                    +e.text #{item.text}

- data = {"items": [{"title": "WI-FI", "text": "Есть", "tooltip": true}, {"title": "Разрешение камеры", "text": "8 Мпикс"}, {"title": "Материал корпуса", "text": "Металл"}]}

            +characteristic-product('', ' ', data, '')

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question