S
S
Sayneone2020-03-16 19:22:36
HTML
Sayneone, 2020-03-16 19:22:36

How to do multiple loops in a PUG/JADE mixin?

Friends, tell me how you can make several cycles in a mixin, despite the fact that when adding a mixin to a page, we list the necessary names in the ad: here is an example

mixin A (...tags, ...styles)
    .content
            .style
                each style in styles
                    a(href='#').style__item= style
            .tags
                each tag in tags
                    a(href='#').tag= tag


The problem lies in the declaration of this mixin, how to delimit tags/styles from each other

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey, 2020-03-17
@AleksRap

mixin A (tags, styles)
    .content
        if(styles)
            .style
                each style in styles
                    a(href='#').style__item= style
         if(tags)
            .tags
                each tag in tags
                    a(href='#').tag= tag

you can call like this
+А(true);
+A(false, true)

etc

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question