- Removed errant "lower()" in the lexer which was causing tags to compile with case-insensitive names, thus messing up custom <%call> names. [ticket:108]
diff --git a/CHANGES b/CHANGES index 37d772c..001e8d0 100644 --- a/CHANGES +++ b/CHANGES
@@ -24,6 +24,11 @@ - Fixed lexing support for whitespace around '=' sign in defs. [ticket:102] + +- Removed errant "lower()" in the lexer which + was causing tags to compile with + case-insensitive names, thus messing up + custom <%call> names. [ticket:108] 0.2.4 - Fixed compatibility with Jython 2.5b1.
diff --git a/lib/mako/lexer.py b/lib/mako/lexer.py index cbaf349..3d75b6f 100644 --- a/lib/mako/lexer.py +++ b/lib/mako/lexer.py
@@ -196,7 +196,7 @@ re.I | re.S | re.X) if match: - (keyword, attr, isend) = (match.group(1).lower(), match.group(2), match.group(3)) + (keyword, attr, isend) = (match.group(1), match.group(2), match.group(3)) self.keyword = keyword attributes = {} if attr:
diff --git a/test/def.py b/test/def.py index 4bc5563..69ce70e 100644 --- a/test/def.py +++ b/test/def.py
@@ -25,7 +25,6 @@ ${mycomp()}""") assert template.render(variable='hi').strip() == """hello mycomp hi""" - def test_def_args(self): template = Template(""" <%def name="mycomp(a, b)">
diff --git a/test/lexer.py b/test/lexer.py index 39d5ac5..17a2ba2 100644 --- a/test/lexer.py +++ b/test/lexer.py
@@ -41,11 +41,7 @@ hi. """ - try: - nodes = Lexer(template).parse() - assert False - except exceptions.SyntaxException, e: - assert str(e) == "Closing tag without opening tag: </%namespace> at line: 6 char: 13" + self.assertRaises(exceptions.SyntaxException, Lexer(template).parse) def test_unmatched_tag(self): template = """ @@ -58,22 +54,23 @@ hi. """ - try: - nodes = Lexer(template).parse() - assert False - except exceptions.SyntaxException, e: - assert str(e) == "Closing tag </%namespace> does not match tag: <%def> at line: 5 char: 13" + self.assertRaises(exceptions.SyntaxException, Lexer(template).parse) def test_nonexistent_tag(self): template = """ <%lala x="5"/> """ - try: - node = Lexer(template).parse() - assert False - except exceptions.CompileException, e: - assert str(e) == "No such tag: 'lala' at line: 2 char: 13" + self.assertRaises(exceptions.CompileException, Lexer(template).parse) + def test_wrongcase_tag(self): + template = """ + <%DEF name="foo()"> + </%def> + + """ + + self.assertRaises(exceptions.CompileException, Lexer(template).parse) + def test_text_tag(self): template = """ ## comment @@ -105,11 +102,7 @@ hi </%def> """ - try: - node = Lexer(template).parse() - assert False - except exceptions.CompileException, e: - assert str(e) == "Missing attribute(s): 'name' at line: 2 char: 9" + self.assertRaises(exceptions.CompileException, Lexer(template).parse) def test_def_syntax_2(self): template = """ @@ -117,11 +110,7 @@ hi </%def> """ - try: - node = Lexer(template).parse() - assert False - except exceptions.CompileException, e: - assert str(e) == "Missing parenthesis in %def at line: 2 char: 9" + self.assertRaises(exceptions.CompileException, Lexer(template).parse) def test_whitespace_equals(self): template = """
diff --git a/test/namespace.py b/test/namespace.py index a3cabd7..7820bb6 100644 --- a/test/namespace.py +++ b/test/namespace.py
@@ -460,7 +460,23 @@ "call body" ] + def test_custom_tag_case_sensitive(self): + t = Template(""" + <%def name="renderPanel()"> + panel ${caller.body()} + </%def> + <%def name="renderTablePanel()"> + <%self:renderPanel> + hi + </%self:renderPanel> + </%def> + + <%self:renderTablePanel/> + """) + assert result_lines(t.render()) == ['panel', 'hi'] + + def test_expr_grouping(self): """test that parenthesis are placed around string-embedded expressions."""