Code

Opened 6 years ago

Closed 6 years ago

#6370 closed (wontfix)

Templates {% block %} does not work properly in {% if %}

Reported by: brandemk@… 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: UI/UX:

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.

Attachments (0)

Change History (2)

comment:1 Changed 6 years ago by Collin Grady <cgrady@…>

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

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.

comment:2 Changed 6 years ago by SmileyChris

  • Resolution set to wontfix
  • Status changed from new to closed

Yep, it's by design.

Add Comment

Modify Ticket

Change Properties
<Author field>
Action
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.