diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index b642765..0abd215 100644
a
|
b
|
class IncludeNode(BaseIncludeNode):
|
165 | 165 | def render(self, context): |
166 | 166 | try: |
167 | 167 | template_name = self.template_name.resolve(context) |
168 | | template = get_template(template_name) |
| 168 | if hasattr(template_name, 'render'): |
| 169 | # The variable itself is a template, no need to get find it. |
| 170 | template = template_name |
| 171 | else: |
| 172 | template = get_template(template_name) |
169 | 173 | return self.render_template(template, context) |
170 | 174 | except: |
171 | 175 | if settings.TEMPLATE_DEBUG: |
diff --git a/docs/ref/templates/builtins.txt b/docs/ref/templates/builtins.txt
index 4e5c124..ddf1954 100644
a
|
b
|
the variable ``template_name``::
|
657 | 657 | |
658 | 658 | {% include template_name %} |
659 | 659 | |
| 660 | .. versionchanged:: 1.4 |
| 661 | Render templates passed directly in context. |
| 662 | |
| 663 | You can also include the contents of a compiled |
| 664 | :class:`~django.template.Template` that is on the template context. |
| 665 | |
660 | 666 | An included template is rendered with the context of the template that's |
661 | 667 | including it. This example produces the output ``"Hello, John"``: |
662 | 668 | |
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 712093b..b7052cf 100644
a
|
b
|
class Templates(unittest.TestCase):
|
1046 | 1046 | 'include13': ('{% autoescape off %}{% include "basic-syntax03" %}{% endautoescape %}', {'first': '&'}, ('& --- ', '& --- INVALID')), |
1047 | 1047 | 'include14': ('{% autoescape off %}{% include "basic-syntax03" with first=var1 only %}{% endautoescape %}', {'var1': '&'}, ('& --- ', '& --- INVALID')), |
1048 | 1048 | |
| 1049 | # render template passed to context |
| 1050 | 'include15': ('{% include tmpl %}', {'tmpl': template.Template('{{ a }} --- {{ b }}'), 'a': 'A'}, ('A --- ', 'A --- INVALID')), |
| 1051 | |
1049 | 1052 | 'include-error01': ('{% include "basic-syntax01" with %}', {}, template.TemplateSyntaxError), |
1050 | 1053 | 'include-error02': ('{% include "basic-syntax01" with "no key" %}', {}, template.TemplateSyntaxError), |
1051 | 1054 | 'include-error03': ('{% include "basic-syntax01" with dotted.arg="error" %}', {}, template.TemplateSyntaxError), |