mirror of
https://github.com/django/django.git
synced 2024-12-22 17:16:24 +00:00
Fixed #27722 -- Reallowed using django.Template in {% include %}.
This commit is contained in:
parent
0595bca221
commit
fe2d288434
@ -180,6 +180,9 @@ class IncludeNode(Node):
|
||||
if template is None:
|
||||
template = context.template.engine.get_template(template_name)
|
||||
cache[template_name] = template
|
||||
# Use the base.Template of a backends.django.Template.
|
||||
elif hasattr(template, 'template'):
|
||||
template = template.template
|
||||
values = {
|
||||
name: var.resolve(context)
|
||||
for name, var in self.extra_context.items()
|
||||
|
@ -1,7 +1,7 @@
|
||||
import warnings
|
||||
|
||||
from django.template import (
|
||||
Context, Engine, TemplateDoesNotExist, TemplateSyntaxError,
|
||||
Context, Engine, TemplateDoesNotExist, TemplateSyntaxError, loader,
|
||||
)
|
||||
from django.test import SimpleTestCase, ignore_warnings
|
||||
from django.utils.deprecation import RemovedInDjango21Warning
|
||||
@ -277,6 +277,11 @@ class IncludeTests(SimpleTestCase):
|
||||
output = outer_tmpl.render(ctx)
|
||||
self.assertEqual(output, 'This worked!')
|
||||
|
||||
def test_include_from_loader_get_template(self):
|
||||
tmpl = loader.get_template('include_tpl.html') # {% include tmpl %}
|
||||
output = tmpl.render({'tmpl': loader.get_template('index.html')})
|
||||
self.assertEqual(output, 'index\n\n')
|
||||
|
||||
def test_include_immediate_missing(self):
|
||||
"""
|
||||
#16417 -- Include tags pointing to missing templates should not raise
|
||||
|
1
tests/template_tests/templates/include_tpl.html
Normal file
1
tests/template_tests/templates/include_tpl.html
Normal file
@ -0,0 +1 @@
|
||||
{% include tmpl %}
|
Loading…
Reference in New Issue
Block a user