Using nunjucks, how can I define some global variables that should always be available within all templates?
Ideally, they would be specified somewhere in the enviro
It's not documented (or perhaps advised), but this works:
var njglobals = require('nunjucks/src/globals');
njglobals.someVar = 'someValue';
You can now use someVar
in your templates.
Be sure not to overwrite any of the existing properties of the njglobals
object, though (for nunjucks@1.0.1
, they are range
, cycler
and joiner
).