foundation / panini

A super simple flat file generator.
Other
592 stars 104 forks source link

Using front matter variables in partials #130

Closed marvinhuebner closed 7 years ago

marvinhuebner commented 7 years ago

I Would like to use front matter variables in a partial.

My panini template looks like:

---
iconPath: /assets/favicon
---

<link rel="manifest" href="{{root}}{{iconPath}}/manifest.json">

And the output looks like this:

view-source_localhost_8000

So i think he ignores the front matter part in partials.

Is this a known bug or a maybe this feature is not included at all?

Thank you in advance.

gakimball commented 7 years ago

Front Matter only works on pages.

In Handlebars, partials use the same context (i.e., variables) as the context in which they were included. So, when you use a partial in a page, you have access to all the same variables you'd have in that page.

It's not possible to change the default context for a partial, which means we can't add new variables like that through Front Matter. So unfortunately this won't be possible.

I'd recommend storing the variable in a data file, called something like assets.yml. Any future paths you need to reuse could be stored there as well.

marvinhuebner commented 7 years ago

Alright.

To store the variable in a data file looks a good alternative. Thanks for the hint!