From c5a899b190d1afa798efade499e8d00a5286fa28 Mon Sep 17 00:00:00 2001 From: Aymeric Augustin Date: Mon, 21 Nov 2011 10:28:12 +0000 Subject: Fixed #16787 -- Restored the ability to {% load %} template tags libraries within packages. Thanks Ivan Sagalaev for the report and patch. git-svn-id: http://code.djangoproject.com/svn/django/trunk@17133 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- .../templates/templatetags/subpackage/__init__.py | 0 .../templates/templatetags/subpackage/echo.py | 7 +++++++ .../templates/templatetags/subpackage/echo_invalid.py | 1 + tests/regressiontests/templates/tests.py | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 7 deletions(-) create mode 100644 tests/regressiontests/templates/templatetags/subpackage/__init__.py create mode 100644 tests/regressiontests/templates/templatetags/subpackage/echo.py create mode 100644 tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py (limited to 'tests') diff --git a/tests/regressiontests/templates/templatetags/subpackage/__init__.py b/tests/regressiontests/templates/templatetags/subpackage/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/tests/regressiontests/templates/templatetags/subpackage/echo.py b/tests/regressiontests/templates/templatetags/subpackage/echo.py new file mode 100644 index 0000000000..0e4e862887 --- /dev/null +++ b/tests/regressiontests/templates/templatetags/subpackage/echo.py @@ -0,0 +1,7 @@ +from django import template + +register = template.Library() + +@register.simple_tag +def echo2(arg): + return arg diff --git a/tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py b/tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py new file mode 100644 index 0000000000..c12ea65507 --- /dev/null +++ b/tests/regressiontests/templates/templatetags/subpackage/echo_invalid.py @@ -0,0 +1 @@ +import nonexistent.module diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py index 712093b934..e2743581ae 100644 --- a/tests/regressiontests/templates/tests.py +++ b/tests/regressiontests/templates/tests.py @@ -1193,17 +1193,22 @@ class Templates(unittest.TestCase): 'inheritance41': ("{% extends 'inheritance36' %}{% block opt %}new{{ block.super }}{% endblock %}", {'numbers': '123'}, '_new1_new2_new3_'), ### LOADING TAG LIBRARIES ################################################# + 'load01': ("{% load testtags subpackage.echo %}{% echo test %} {% echo2 \"test\" %}", {}, "test test"), + 'load02': ("{% load subpackage.echo %}{% echo2 \"test\" %}", {}, "test"), # {% load %} tag, importing individual tags - 'load1': ("{% load echo from testtags %}{% echo this that theother %}", {}, 'this that theother'), - 'load2': ("{% load echo other_echo from testtags %}{% echo this that theother %} {% other_echo and another thing %}", {}, 'this that theother and another thing'), - 'load3': ("{% load echo upper from testtags %}{% echo this that theother %} {{ statement|upper }}", {'statement': 'not shouting'}, 'this that theother NOT SHOUTING'), + 'load03': ("{% load echo from testtags %}{% echo this that theother %}", {}, 'this that theother'), + 'load04': ("{% load echo other_echo from testtags %}{% echo this that theother %} {% other_echo and another thing %}", {}, 'this that theother and another thing'), + 'load05': ("{% load echo upper from testtags %}{% echo this that theother %} {{ statement|upper }}", {'statement': 'not shouting'}, 'this that theother NOT SHOUTING'), + 'load06': ("{% load echo2 from subpackage.echo %}{% echo2 \"test\" %}", {}, "test"), # {% load %} tag errors - 'load4': ("{% load echo other_echo bad_tag from testtags %}", {}, template.TemplateSyntaxError), - 'load5': ("{% load echo other_echo bad_tag from %}", {}, template.TemplateSyntaxError), - 'load6': ("{% load from testtags %}", {}, template.TemplateSyntaxError), - 'load7': ("{% load echo from bad_library %}", {}, template.TemplateSyntaxError), + 'load07': ("{% load echo other_echo bad_tag from testtags %}", {}, template.TemplateSyntaxError), + 'load08': ("{% load echo other_echo bad_tag from %}", {}, template.TemplateSyntaxError), + 'load09': ("{% load from testtags %}", {}, template.TemplateSyntaxError), + 'load10': ("{% load echo from bad_library %}", {}, template.TemplateSyntaxError), + 'load11': ("{% load subpackage.echo_invalid %}", {}, template.TemplateSyntaxError), + 'load12': ("{% load subpackage.missing %}", {}, template.TemplateSyntaxError), ### I18N ################################################################## -- cgit v1.3