Opened 17 years ago
Closed 17 years ago
#6370 closed (wontfix)
Templates {% block %} does not work properly in {% if %}
Description ¶
When I use the following code:
{% if site %}
<title>{% block titlebar %}{% endblock %} § {{ site.name }}</title>
{% else %}
<title>{% block titlebar %}{% endblock %} § Website</title>
{% endif %}
I get an error: titlebar block appears more than once.
While I do not see why an block cannot appear more than once, I do not see a reason that that cannot be valid. The titlebar block will only be rendered once.
Note:
See TracTickets
for help on using tickets.
I'm pretty sure this is by design, because of how template extension works - you simply need to move your if.
<title>{% block titlebar %}{% endblock %} § {% if site %}{{ site.name }}{% else %}Website{% endif %}</title>
Less duplicated html, yet does the exact same thing your does.