assemble.io-Yaml数据在局部中的上下文不起作用 [英] assemble.io - context of yaml data in partials not working

查看:97
本文介绍了assemble.io-Yaml数据在局部中的上下文不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用Assemble的局部视图中呈现YAML内容时遇到了问题

I have an issue with YAML rendering content within partials using Assemble

这是我的细分:

layout/deafualt.hbs

<body>
        {{pagetitle}} <!-- THIS WILL RENDER 'HELLO WORLD' FINE -->
        <header role="banner">
            {{> _header }}
        </header>
        <main role="main">
            {{> body }}
        </main>
        <footer role="contentinfo">
            {{> _footer }}
        </footer>
    </body>

pages/car.hbs

---
pagetitle: "HELLO WORLD"
---
{{#car }}
    {{> banner }}
    {{> content }}
    {{> explore }}
    {{> feature }}
    {{> social }}
{{/car }}

modules/content.hbs

<h1>{{pagetitle}}</h1> <!-- THIS ***WON'T*** RENDER 'HELLO WORLD'-->
<h>Im a sub-heading</h2>

我想这与上下文有关,但是我尝试了各种排列都无济于事.

I imagine that its something to do with the context but I've tried various permutations to no avail.

任何指针都非常感激.

A.

推荐答案

这不是组装"问题.使用把手时,在嵌套块中使用局部时会变得棘手.

This is a handlebars issue more than Assemble. With handlebars it gets tricky when you use partials in nested blocks.

给出示例,在content.hbs中尝试执行{{car.pagetitle}},因为您位于{{#car}}...{{/car}}块中.

Given your example, in content.hbs try doing {{car.pagetitle}} since you're inside the {{#car}}...{{/car}} block.

这篇关于assemble.io-Yaml数据在局部中的上下文不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆