Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Would like to use helpers in Front Matter variables #66

Closed
chrisbloom7 opened this issue Jun 8, 2016 · 1 comment
Closed

Would like to use helpers in Front Matter variables #66

chrisbloom7 opened this issue Jun 8, 2016 · 1 comment

Comments

@chrisbloom7
Copy link

Given the following setup:

helpers
  primary.js
pages
  index.html
partials
  heading.html

When index.html contains:


---
heading: You got {{#primary}}200{{/primary}} points!

---
{{> heading}}
<row>
  <columns small="12" large="12">
    <p>{{#primary}}Well done!{{/primary}}</p>
  </columns>
</row>

And heading.html contains:

<row>
  <columns small="12" large="12">
    <h1>
      {{ heading }}
    </h1>
  </columns>
</row>

Then the helper isn't being applied and I end up with You got {{#primary}}200{{/primary}} points! in that section, though it does properly apply the helper to the next section.

@gakimball
Copy link
Contributor

Not possible, unfortunately.

The Front Matter is static metadata. When Panini renders a page, it pulls the Front Matter out of the original page, and converts it into a data object. That data object is then accessible in Handlebars, like so:

---
name: Chris
---

<p>Hi, {{ name }}</p>

The Front Matter has to be parsed and removed before Handlebars can do its thing—otherwise you've created a circular dependency.

I'm not sure what your {{#primary}} helper does, but if it's just a formatting thing (like adding HTML around the contents), there are ways to do that without having dynamic Front Matter.

It's best to think of the Front Matter as pure data, and not having anything to do with presentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants