D
D
drtvader2016-05-04 15:34:53
Pug
drtvader, 2016-05-04 15:34:53

What is the correct way to write a loop in Jade?

Hey! How to correctly register the appearance of +e.block in the cycle, i.e. if we allow, I will write +breadcrumb('One', 'Two') I only added +e.block after the first item.

mixin breadcrumb(...items)
    +b('ul').breadcrumb&attributes(attributes)
        each item in items
            +e('li').item
                +e('a')(href="#" title=item).link= item
            +e.block

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
drtvader, 2016-05-04
@drtvader

mixin breadcrumb(...items)
    // BEGIN section.b-breadcrumb
    +b('ul').breadcrumb&attributes(attributes)
        each item in items
            +e('li').item
                +e('a')(href="#" title=item).link= item
            +e.block
                +e('span').dot
    // END section.b-breadcrumb

Settled on this option, The last added +e.block will be hidden via css

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question