K
K
Kirill2020-10-17 12:45:02
Pug
Kirill, 2020-10-17 12:45:02

How to pass to the block (bam) what element it is in pug?

Making my first project with pug and splitting it into components for the first time. Faced such a problem.
Let's say there are header, footer, and logo blocks. Each block is in its own folder and has its own scss, pug and js file if needed.

logo.pug:
img.logo(src="img/logo.png")

In order for logo.pug to be reusable I don't have to give it positioning on the logo class. But how to make it so that when you include logo.pug inside the header or footer, the logo block is substituted with the header__logo or footer__logo class, depending on the context? tried to use bemto mixins, but could not solve this issue. I will be glad to any solutions, preferably simple for development and implementation.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
inkShio, 2020-10-17
@Lirrr

logo.pug

mixin logo(className)
  img.logo(src="img/logo.png", class= className)

conclusion
+logo()
+logo('header__logo')

A
Alex Glebov, 2020-10-17
@SkiperX

.page
  .page__header
    +header
  .page__footer
    +footer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question