How can I define global variables in nunjucks?

前端 未结 3 1448
独厮守ぢ
独厮守ぢ 2021-01-12 07:30

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

3条回答
  •  春和景丽
    2021-01-12 08:08

    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.

提交回复
热议问题