How can I define global variables in nunjucks?
问题 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 environment or config options and not have to be merged into the context dict with each call to nunjucksEnvironment.render . 回答1: I was just looking for this and came here. Looks like there's now a recommended way which was added in recently in version 1.0.6. See Environment.addGlobal. 回答2: It's not documented (or perhaps advised), but