Nested layout variables

无人久伴 提交于 2019-12-10 19:20:02

问题


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.



来源:https://stackoverflow.com/questions/23856827/nested-layout-variables

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!