Opened 6 years ago

Closed 6 years ago

#10003 closed (invalid)

if and extends in template

Reported by: 0ptr Owned by: nobody
Component: Template system Version: 1.0
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

{% if mobile %}
{% extends 'base_mobile.html' %}
{% else %}
{% extends 'base_normal.html' %}
{% endif %}


Throws following exception:

Exception Type:	TemplateSyntaxError
Exception Value:	
Invalid block tag: 'else'
Exception Location:	/home/dsduser/django-synble/django/template/__init__.py in invalid_block_tag, line 333

I think this should be supported. Second option is to write include correctly so that include does not broke inheritance. E.g.:

basbase.html: has block

base.html: include "basebase.html"

logic.html: extends "base.html", inheritance of basbase.html block does not work here anymore.

Change History (1)

comment:1 Changed 6 years ago by 0ptr

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to invalid
  • Status changed from new to closed

Ok actually better way is to return the template name from context processor and extend it directly

{% extends ua_based_template %}

Note: See TracTickets for help on using tickets.
Back to Top