Ticket #1650: template-loader.diff
File template-loader.diff, 3.1 KB (added by , 19 years ago) |
---|
-
django/template/loader_tags.py
50 50 if self.parent_name_expr: 51 51 error_msg += " Got this from the %r variable." % self.parent_name_expr #TODO nice repr. 52 52 raise TemplateSyntaxError, error_msg 53 if hasattr(parent, 'render'): 54 return parent 53 55 try: 54 56 source, origin = find_template_source(parent, self.template_dirs) 55 57 except TemplateDoesNotExist: … … 137 139 138 140 This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) 139 141 uses the literal value "base" as the name of the parent template to extend, 140 or ``{% extends variable %}`` uses the value of ``variable`` as the name 141 of the parent template to extend. 142 or ``{% extends variable %}`` uses the value of ``variable`` as either the 143 name of the parent template to extend (if it evaluates to a string,) or as 144 the parent tempate itelf (if it evaluates to a Template object). 142 145 """ 143 146 bits = token.contents.split() 144 147 if len(bits) != 2: -
tests/othertests/templates.py
314 314 # Three-level inheritance with {{ block.super }} from parent and grandparent 315 315 'inheritance23': ("{% extends 'inheritance20' %}{% block first %}{{ block.super }}b{% endblock %}", {}, '1_ab3_'), 316 316 317 # Inheritance from local context without use of template loader 318 'inheritance24': ("{% extends context_template %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")}, '1234'), 319 320 # Inheritance from local context with variable parent template 321 'inheritance25': ("{% extends context_template.1 %}{% block first %}2{% endblock %}{% block second %}4{% endblock %}", {'context_template': [template.Template("Wrong"), template.Template("1{% block first %}_{% endblock %}3{% block second %}_{% endblock %}")]}, '1234'), 322 317 323 ### I18N ################################################################## 318 324 319 325 # {% spaceless %} tag -
docs/templates.txt
368 368 369 369 This tag may be used in two ways: ``{% extends "base" %}`` (with quotes) uses 370 370 the literal value "base" as the name of the parent template to extend, or ``{% 371 extends variable %}`` uses the value of ``variable`` as the name of the parent 372 template to extend. 371 extends variable %}`` uses the value of ``variable`` as either the name of the 372 parent template to extend (if it evaluates to a string,) or as the parent 373 tempate itelf (if it evaluates to a Template object). 373 374 375 374 376 See `Template inheritance`_ for more information. 375 377 376 378 filter