I
I
Ivan2019-05-26 17:16:20
css
Ivan, 2019-05-26 17:16:20

How to issue cards through Pug?

I work with pug and bootstrap4, according to the technical task, I need to make sure that the card is laid out once and then called 6 times.
at first I thought what should be done on mixins, but the technical specification clearly states that the card should be laid out once .
I decided that it was worth making a separate page, making one card in it and inserting it into the pag 6 times using
include index.html.
Tell me, who would do it?
5cea9f8671581648642461.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ivan, 2019-05-26
@BenderIsGreat34

implemented in this way

- var gmi = "../img/team-image.png"
            mixin teams(worker)
              div.myCard
                img(class="workers" width="220px", src=gmi, alt="teams")
                h3(class="h3-teams")= worker.h3
                p(class="p-teams")= worker.p
            each item in [{h3: "SEMF UCUK", p:"CEO & FOUNDER"}, {h3: "DIK ADALIN", p:"ENGINEERING"}, {h3: "JENG KOL", p:"DESIGNER"}, {h3: "PET ROMAK", p: "MARKETING"}] 
              +teams(item)

A
Alex Glebov, 2019-05-26
@SkiperX

https://pugjs.org/language/iteration.html
via each

- 
  var items = [{
img: '',
title: 'semf ucuk',
description: ""
},
{
img: '',
title: 'semf ucuk',
description: ""
},
{
img: '',
title: 'dik',
description: ""
},
{
img: '',
title: 'jeng',
description: ""
},
{
img: '',
title: 'pet',
description: ""
}]

each item in items
  div.card
    .title!=item.title
    .desc!=item.description

you can also make a card a mixin and pass items through parameters, one at a time or all at once
+card({[],[],[]})

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question