问题
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