-
Notifications
You must be signed in to change notification settings - Fork 46
Arbitrary, site-wide template variables in config file #94
Comments
Just a quick note - I'm doing this using a yaml file and a hook. The code is at https://gist.github.com/4546750. You just need to add a file called globals.yaml to your root directory, and any variables are merged into the template variables dictionary. |
Huh. I don't remember seeing this issue... anyways, good news! You can already do this. This is probably one of the holes in the documentation, but you can add anything you like to the config file, and it will be available under the
A template:
and this works. The same is true of individual pages. Any thing that the parser finds in the YAML header that doesn't make sense to it, it just passes along under the The decision to use YAML instead of a Python file was largely because at the time, the the Python import path was a dark and scary place for me: YAML did everything I wanted, and was easier to load. Although having settings in a turing complete format has it's advantages, I don't think it is really something that is needed here. |
Awesome, that's good to know. Thanks, Mike! |
That is handy - yeah, a note in the documentation would be helpful. |
It would be great to have the ability to add arbitrary, site-wide template variables in the config file.
For example, in
config
, you might have a map calledtemplate_globals
:And anything in
template_globals
would be available to every template, e.g.,The text was updated successfully, but these errors were encountered: