diff --git a/CHANGES b/CHANGES index 37d772c1691202fb4b04317ecef2ba05196ac55b..001e8d05de7491aac14da4413cd5afb3daaba732 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 cbaf3493a985187aa1854c4e9f82e5d290487df0..3d75b6fb69145d5b2922b003ee2955673d0fa321 100644 --- a/lib/mako/lexer.py +++ b/lib/mako/lexer.py @@ -196,7 +196,7 @@ class Lexer(object): 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 4bc55631f5024faba348ea8cc565eb6622428700..69ce70ebdd9123b78d427097f685a768b38eaa04 100644 --- a/test/def.py +++ b/test/def.py @@ -25,7 +25,6 @@ class DefTest(unittest.TestCase): ${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 39d5ac565c890919b64dae6f815b7a20e1b2cfd4..17a2ba20c14ea0e609e2b376214fb176abca2b9d 100644 --- a/test/lexer.py +++ b/test/lexer.py @@ -41,11 +41,7 @@ class LexerTest(unittest.TestCase): 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 @@ class LexerTest(unittest.TestCase): 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 @@ class LexerTest(unittest.TestCase): 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 @@ class LexerTest(unittest.TestCase): 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 a3cabd7f4decb2bd525f81049921d3ae889635b0..7820bb6d83ae770c86ff149f7f2f93fb09ff8194 100644 --- a/test/namespace.py +++ b/test/namespace.py @@ -460,7 +460,23 @@ class NamespaceTest(unittest.TestCase): "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."""