assemble.io - context of yaml data in partials not working

泄露秘密 提交于 2019-12-11 09:29:40

问题


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

Here is my breakdown:

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.

Any pointers greatly appreciated.

A.


回答1:


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

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



来源:https://stackoverflow.com/questions/25720831/assemble-io-context-of-yaml-data-in-partials-not-working

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