Search code examples
assemble

Nested layout variables


Is there a way to access YFM properties defined in a child layout in its parent layout?

For example, given a child layout page.hbs:

---
layout: wrapper.hbs
no_header: true
----
<div class="wrapper">{{> body }}</div>

I'd like to access the no_header YFM property defined in page.hbs in the parent layout wrapper.hbs:

<html>
    <body>
        {{#unless layout.no_header}}<header></header>{{/if}}
        {{> body }}
    </body>
</html>

Solution

  • The front matter merges up so you should be able to get it on the root of the context.

    Try doing {{#unless no_header}}.

    Edit: updated based on comment below.