mirror of
https://github.com/django/django.git
synced 2025-10-24 06:06:09 +00:00
Fixed #23516 -- Added caching of include tag Template objects
This also speeds up for loops that render the same template multiple times.
This commit is contained in:
committed by
Tim Graham
parent
2a7c59cd88
commit
a391b17ad2
@@ -196,3 +196,17 @@ class IfChangedTests(SimpleTestCase):
|
||||
template = self.engine.from_string('{% ifchanged %}{% cycle "1st time" "2nd time" %}{% endifchanged %}')
|
||||
output = template.render(Context({}))
|
||||
self.assertEqual(output, '1st time')
|
||||
|
||||
def test_include(self):
|
||||
"""
|
||||
#23516 -- This works as a regression test only if the cached loader
|
||||
isn't used. Hence we don't use the @setup decorator.
|
||||
"""
|
||||
engine = Engine(loaders=[
|
||||
('django.template.loaders.locmem.Loader', {
|
||||
'template': '{% for x in vars %}{% include "include" %}{% endfor %}',
|
||||
'include': '{% ifchanged %}{{ x }}{% endifchanged %}',
|
||||
}),
|
||||
])
|
||||
output = engine.render_to_string('template', dict(vars=[1, 1, 2, 2, 3, 3]))
|
||||
self.assertEqual(output, "123")
|
||||
|
||||
Reference in New Issue
Block a user