Nested layout variables

2019-07-04 16:17发布

问题:

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>

回答1:

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.



标签: assemble