diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index 38b2fff9fd..f91699d7f2 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -158,7 +158,7 @@ def do_extends(parser, token): name of the parent template to extend (if it evaluates to a string) or as the parent tempate itelf (if it evaluates to a Template object). """ - bits = token.contents.split() + bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError, "'%s' takes one argument" % bits[0] parent_name, parent_name_expr = None, None @@ -179,7 +179,7 @@ def do_include(parser, token): {% include "foo/some_include" %} """ - bits = token.contents.split() + bits = token.split_contents() if len(bits) != 2: raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[0] path = bits[1] diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index c51122266a..33114c7476 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -661,6 +661,8 @@ class Templates(unittest.TestCase): 'include02': ('{% include "basic-syntax02" %}', {'headline': 'Included'}, "Included"), 'include03': ('{% include template_name %}', {'template_name': 'basic-syntax02', 'headline': 'Included'}, "Included"), 'include04': ('a{% include "nonexistent" %}b', {}, "ab"), + 'include 05': ('template with a space', {}, 'template with a space'), + 'include06': ('{% include "include 05"%}', {}, 'template with a space'), ### NAMED ENDBLOCKS ####################################################### @@ -760,6 +762,12 @@ class Templates(unittest.TestCase): # Inheritance from a template that doesn't have any blocks 'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'), + # Set up a base template with a space in it. + 'inheritance 28': ("{% block first %}!{% endblock %}", {}, '!'), + + # Inheritance from a template with a space in its name should work. + 'inheritance29': ("{% extends 'inheritance 28' %}", {}, '!'), + ### I18N ################################################################## # {% spaceless %} tag