#1650 closed enhancement (fixed)
[patch] Allow templates to extend from parents in local context
Description ¶
It can be useful for templates to extend a base template which does not necessarily exist on the filesystem -- for example, the base template may be stored in the database, or it may be generated at runtime.
This patch allows a template object in the curent context to be used as a base template for inheritance.
Example:
>>> from django.template import Context, Template, loader >>> child = Template("{% extends parent %}{% block one %}Hello, {{ name }}{% endblock %}") >>> parent = Template("<h1>{% block one %}Name{% endblock %}</h1>") >>> child.render(Context({'name': 'World', 'parent': parent}))
returns "<h1>Hello, World</h1>"
Change History (2)
by , 19 years ago
Attachment: | template-loader.diff added |
---|
comment:1 by , 19 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Note:
See TracTickets
for help on using tickets.
Fixed in [3465].