foundation / panini

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

Allow Front Matter data to override External Data #101

Closed fabritw closed 7 years ago

fabritw commented 7 years ago

I'm using External Data files to define global variables. In some templates, it would be very helpful to override the globals however (https://github.com/zurb/panini#data).

For example:

// src/data/globals.yml - define global variable
url: "www.mysite.com"

// src/pages/signup.html - override global variable
---
globals.url: "signup.mysite.com"
---
renatodeleao commented 7 years ago

This would be nice . Right now i'm bypassing this with an if else at the base template, but it feels like extra verbosity.

{{if url}}{{url}}{{else}}{{globals.url}}{{/if}}

gakimball commented 7 years ago

We could do a deep merge of properties, where now we just overwrite everything if two keys conflict. So you could write:

globals:
  url: 'signup.mysite.com'

That at least prevents us from needing to explain object path notation.

gakimball commented 7 years ago

Implemented this in ae6b85352b6adf3dd1d8d1b086f0010cd2fa6823