Skip to content

Instantly share code, notes, and snippets.

@elvestar
Last active September 5, 2015 06:01
Show Gist options
  • Save elvestar/418a8fd8b79130dd6080 to your computer and use it in GitHub Desktop.
Save elvestar/418a8fd8b79130dd6080 to your computer and use it in GitHub Desktop.
Jinja2:定义全局变量,并在各个模板中使用
{% set LOG_CLASS_BRIEF = {
'user_behaviour': '用户行为数据',
'non_user_behaviour': '非用户行为业务数据',
'monitor': '监控数据',
'debug': '错误或调试数据'} %}
{% import '_globals.html' as globals %}
<h4>日志分类:</h4>
<p>
<a href="#" class="btn btn-sm btn-default">{{ globals.LOG_CLASS_BRIEF[log_config.log_class] }}</a>
</p>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment