A
A
Alexey Dubrovin2021-06-30 08:57:26
Pug
Alexey Dubrovin, 2021-06-30 08:57:26

How to implement a dynamic class through a mixin?

I know mixins.
I'm trying to dynamically generate the
Input class for it to work:

var items = [
        {bg:'blue},
        {bg:'yellow'},
        {bg:'red'}
        ]

I call the mixin itself through the construction:
each item in items
            +item(item)


Mixin:
mixin item(item)
    .inform-items__item.inform-items__item_bg_${item.bg}


How to implement this functionality?

***
I know that there is an implementation by type
div(class=`inform-items__item inform-items__item_bg_${item.bg}`)

I want to know if there is another option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-06-30
@alekcena

mixin item(item)
  .inform-items__item(class=`inform-items__item_bg_${item.bg}`)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question