Nested layout variables

2019-07-04 16:32发布

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>

标签: assemble
1条回答
Root(大扎)
2楼-- · 2019-07-04 17:03

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.

查看更多
登录 后发表回答