Conditional block

Why does

{% if page.description %}
  {% block description %}
    {{ page.description }}
  {% endblock description %}
{% endif %}

does not work but

{% block description %}
  {% if page.description %}
    {{ page.description }}
  {% endif %}
{% endblock description %}

do?

I would like to overwrite the block only if page.description is defined, but I only succeed in replacing it with nothing or page.description if it exists.

Blocks can’t be nested in conditions due to the way Tera (and Jinja2) works, I don’t think it’s doable to change that.

2 Likes