Opened 17 years ago
Closed 17 years ago
#6370 closed (wontfix)
Templates {% block %} does not work properly in {% if %}
Reported by: | Owned by: | nobody | |
---|---|---|---|
Component: | Template system | Version: | 0.96 |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
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.