Skip to content

Instantly share code, notes, and snippets.

@federicomichela
Created January 31, 2018 10:56
Show Gist options
  • Save federicomichela/4fe321aee5695cbf57d98b843cba0f92 to your computer and use it in GitHub Desktop.
Save federicomichela/4fe321aee5695cbf57d98b843cba0f92 to your computer and use it in GitHub Desktop.
JINJA2 - Set conditional variables ( Macros )
{% macro _page_title() -%}
{% block page_title %}
{% if page_id == 'some-string' %}
{% trans %}Some String{% endtrans %}
{% elif page_id == 'some-other-string' %}
{% trans %}Some Other String{% endtrans %}
{% else %}
{% trans %}General String{% endtrans %}
{% endif %}
{% endblock %}
{%- endmacro %}
{% set page_title = _page_title() %}
<h4>{{page_title}}</h4>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment