Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

[1.0.X]: Fixed #10094 -- Fixed the `include` and `extends` template t…

…ags to work with filenames with spaces, patch from mcroydon.

Backport of r10211 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@10212 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit 487a7fdccee5b71f1f44acaafbaec58fa05120d5 1 parent daae84a
Gary Wilson Jr. authored March 30, 2009
4  django/template/loader_tags.py
@@ -158,7 +158,7 @@ def do_extends(parser, token):
158 158
     name of the parent template to extend (if it evaluates to a string) or as
159 159
     the parent tempate itelf (if it evaluates to a Template object).
160 160
     """
161  
-    bits = token.contents.split()
  161
+    bits = token.split_contents()
162 162
     if len(bits) != 2:
163 163
         raise TemplateSyntaxError, "'%s' takes one argument" % bits[0]
164 164
     parent_name, parent_name_expr = None, None
@@ -179,7 +179,7 @@ def do_include(parser, token):
179 179
 
180 180
         {% include "foo/some_include" %}
181 181
     """
182  
-    bits = token.contents.split()
  182
+    bits = token.split_contents()
183 183
     if len(bits) != 2:
184 184
         raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[0]
185 185
     path = bits[1]
8  tests/regressiontests/templates/tests.py
@@ -647,6 +647,8 @@ def get_template_tests(self):
647 647
             'include02': ('{% include "basic-syntax02" %}', {'headline': 'Included'}, "Included"),
648 648
             'include03': ('{% include template_name %}', {'template_name': 'basic-syntax02', 'headline': 'Included'}, "Included"),
649 649
             'include04': ('a{% include "nonexistent" %}b', {}, "ab"),
  650
+            'include 05': ('template with a space', {}, 'template with a space'),
  651
+            'include06': ('{% include "include 05"%}', {}, 'template with a space'),
650 652
 
651 653
             ### NAMED ENDBLOCKS #######################################################
652 654
 
@@ -746,6 +748,12 @@ def get_template_tests(self):
746 748
             # Inheritance from a template that doesn't have any blocks
747 749
             'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'),
748 750
 
  751
+            # Set up a base template with a space in it.
  752
+            'inheritance 28': ("{% block first %}!{% endblock %}", {}, '!'),
  753
+
  754
+            # Inheritance from a template with a space in its name should work.
  755
+            'inheritance29': ("{% extends 'inheritance 28' %}", {}, '!'),
  756
+
749 757
             ### I18N ##################################################################
750 758
 
751 759
             # {% spaceless %} tag

0 notes on commit 487a7fd

Please sign in to comment.
Something went wrong with that request. Please try again.