嵌套布局变量 [英] Nested layout variables
本文介绍了嵌套布局变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
是否可以在其父级布局中访问在子级布局中定义的YFM属性?
Is there a way to access YFM properties defined in a child layout in its parent layout?
例如,给定子布局页面.hbs:
For example, given a child layout page.hbs:
---
layout: wrapper.hbs
no_header: true
----
<div class="wrapper">{{> body }}</div>
我想访问父布局wrapper.hbs中page.hbs中定义的no_header
YFM属性:
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>
推荐答案
前面的问题合并了,因此您应该可以在上下文的根上获取它.
The front matter merges up so you should be able to get it on the root of the context.
尝试做{{#unless no_header}}
.
根据下面的评论更新.
这篇关于嵌套布局变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文