I
I
Igor Myasnikov2017-09-08 15:44:50
Pug
Igor Myasnikov, 2017-09-08 15:44:50

How to make a Pug Mixin?

Good day.
A small problem with this Pug mixin:

mixin workflowOption(Name, Count, text)
    .workflow-option
                    .top
                        .arrows
                        .option-name
                            p= Name
                        .options-count
                            span= Count
                    .option-content
                        p.content-details Workflow-detalies
                        .container
                            .cards
                                .card
                                    .image
                                        .left
                                        .right
                                    p.text= text
                                    .icons
                                        .check
                                            input(type="checkbox" id="option-check")
                                            label(for="option-check")
                                        .delete
                                        .settings
                                .add-cart
                                    .add-rule
                                        p Add Rule
                                    .add-compound-rule
                                        p Add <br> Compound Rule

How to do so. what would, depending on Count(0,1,2,3...) create an equal number of div.cards?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mrSand, 2017-09-11
@mrSand

probably so:

- var i = 0
while i < Count
  .card
  - i++
  .image
    .left
    .right
   ....

If at the same time it is necessary that Name and text be different, then create an object array with data.
then the code will be even simpler
each elem,i in data
  .card
    .image
      .left
      .right
      p.text= elem.text
      ...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question