|
@@ -243,6 +243,26 @@ class IncludeTests(SimpleTestCase):
|
|
|
output = outer_tmpl.render(ctx)
|
|
|
self.assertEqual(output, 'This worked!')
|
|
|
|
|
|
+ def test_include_template_iterable(self):
|
|
|
+ engine = Engine.get_default()
|
|
|
+ outer_temp = engine.from_string('{% include var %}')
|
|
|
+ tests = [
|
|
|
+ ('admin/fail.html', 'index.html'),
|
|
|
+ ['admin/fail.html', 'index.html'],
|
|
|
+ ]
|
|
|
+ for template_names in tests:
|
|
|
+ with self.subTest(template_names):
|
|
|
+ output = outer_temp.render(Context({'var': template_names}))
|
|
|
+ self.assertEqual(output, 'index\n')
|
|
|
+
|
|
|
+ def test_include_template_none(self):
|
|
|
+ engine = Engine.get_default()
|
|
|
+ outer_temp = engine.from_string('{% include var %}')
|
|
|
+ ctx = Context({'var': None})
|
|
|
+ msg = 'No template names provided'
|
|
|
+ with self.assertRaisesMessage(TemplateDoesNotExist, msg):
|
|
|
+ outer_temp.render(ctx)
|
|
|
+
|
|
|
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')})
|