mirror of
https://github.com/django/django.git
synced 2025-07-19 17:19:12 +00:00
[1.0.X]: Fixed #10094 -- Fixed the include
and extends
template tags 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
This commit is contained in:
parent
daae84a8e0
commit
487a7fdcce
@ -158,7 +158,7 @@ def do_extends(parser, token):
|
|||||||
name of the parent template to extend (if it evaluates to a string) or as
|
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).
|
the parent tempate itelf (if it evaluates to a Template object).
|
||||||
"""
|
"""
|
||||||
bits = token.contents.split()
|
bits = token.split_contents()
|
||||||
if len(bits) != 2:
|
if len(bits) != 2:
|
||||||
raise TemplateSyntaxError, "'%s' takes one argument" % bits[0]
|
raise TemplateSyntaxError, "'%s' takes one argument" % bits[0]
|
||||||
parent_name, parent_name_expr = None, None
|
parent_name, parent_name_expr = None, None
|
||||||
@ -179,7 +179,7 @@ def do_include(parser, token):
|
|||||||
|
|
||||||
{% include "foo/some_include" %}
|
{% include "foo/some_include" %}
|
||||||
"""
|
"""
|
||||||
bits = token.contents.split()
|
bits = token.split_contents()
|
||||||
if len(bits) != 2:
|
if len(bits) != 2:
|
||||||
raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[0]
|
raise TemplateSyntaxError, "%r tag takes one argument: the name of the template to be included" % bits[0]
|
||||||
path = bits[1]
|
path = bits[1]
|
||||||
|
@ -647,6 +647,8 @@ class Templates(unittest.TestCase):
|
|||||||
'include02': ('{% include "basic-syntax02" %}', {'headline': 'Included'}, "Included"),
|
'include02': ('{% include "basic-syntax02" %}', {'headline': 'Included'}, "Included"),
|
||||||
'include03': ('{% include template_name %}', {'template_name': 'basic-syntax02', 'headline': 'Included'}, "Included"),
|
'include03': ('{% include template_name %}', {'template_name': 'basic-syntax02', 'headline': 'Included'}, "Included"),
|
||||||
'include04': ('a{% include "nonexistent" %}b', {}, "ab"),
|
'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 #######################################################
|
### NAMED ENDBLOCKS #######################################################
|
||||||
|
|
||||||
@ -746,6 +748,12 @@ class Templates(unittest.TestCase):
|
|||||||
# Inheritance from a template that doesn't have any blocks
|
# Inheritance from a template that doesn't have any blocks
|
||||||
'inheritance27': ("{% extends 'inheritance26' %}", {}, 'no tags'),
|
'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 ##################################################################
|
### I18N ##################################################################
|
||||||
|
|
||||||
# {% spaceless %} tag
|
# {% spaceless %} tag
|
||||||
|
Loading…
x
Reference in New Issue
Block a user