A
A
ayapergenov2016-02-11 14:41:59
Pug
ayapergenov, 2016-02-11 14:41:59

How to exclude a block from a page using a mixin?

Let's say there is a main.jade page that has a header block in which the block is connected

+header-presentation(data)

How to write a mixin so that on another page, for example, page.jade disable the display of the block
+header-presentation(data)
?
I started the solution like this:
In the header block, I created the data/header.js folder and added
the parameter to it
"header": {
    "main": {
        "header-presentation": true
    }
}

In the header.jade file
mixin header(data)
    header.header
        .header__top
        .header__bottom
            .header__inner
                +header-presentation(data)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Khokhlov, 2016-02-11
@ayapergenov

I use jade for layout. Here is an example of how I would solve the problem of disabling the block in the header depending on the page.
layout/_default.jade

include ../mixins/_mixins
doctype html
html(lang="ru-RU" class="no-js")
  include ../parts/_head
  body
    .wrapper#wrapper
      block header
      include ../parts/_header
      .content#content
        block content
      block footer
      include ../parts/_footer

parts/_header.jade
header.header
  .header__top
    .header__bottom
      .header__inner
        if (headerPresentation)
          +header-presentation(data)

page.jade
extends layouts/_default
block head
  - pageTitle = 'Title';
block header
  - headerPresentation = false;
block content
block footer

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question