﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2830	Patch to add subviews for template tags	gch@…	Adrian Holovaty	"In {{{django/template/__init__.py}}}, there exists a special tag function for performing common inclusion tasks, basically to insert the output of another template into a given template.

This is quite useful, but in most cases it'd be better for a template tag to call a python function rather than just inserting another template.  I took the code for {{{inclusion_tag}}}, and created a new tag function, {{{subview_tag}}}, which instead uses a python function to generate content for a template tag.  Like {{{inclusion_tag}}}, it is allowed to take the context and just pass it along.

In my case, I use subview_tags to be able to write custom tags in templates that end up doing rather complex tasks in python, without having to go through the normal hassle.

Here's an example of using {{{subview_tag}}}:

{{{
#!python
# Subview function
def my_subview(context, some_argument):
    return ""This is an example page, with an argument %s"" % some_argument

# register a new syntax tag: {% view my_argument %}
register.subview_tag('view', takes_context=True)(my_subview)
}}}"	enhancement	closed	Template system		normal	wontfix			Unreviewed	0	0	0	0	0	0
