Skip to content
Snippets Groups Projects
Commit a8bb52a9 authored by Mike Bayer's avatar Mike Bayer
Browse files

- further escaping added for multibyte expressions in %def, %call attributes

[ticket:24]
parent 2e9289c5
No related branches found
No related tags found
No related merge requests found
......@@ -9,6 +9,8 @@ propigates __nonzero__ method so it evaulates to False if not present,
True otherwise. this way you can say % if caller:\n ${caller.body()}\n% endif
- <%include> has an "args" attribute that can pass arguments to the called
template (keyword arguments only, must be declared in that page's <%page> tag.)
- further escaping added for multibyte expressions in %def, %call attributes
[ticket:24]
0.1.3
- ***Small Syntax Change*** - the single line comment character is now
......
......@@ -191,7 +191,7 @@ class Lexer(object):
if attr:
for att in re.findall(r"\s*(\w+)\s*=\s*(?:'([^']*)'|\"([^\"]*)\")", attr):
(key, val1, val2) = att
attributes[key] = val1 or val2
attributes[key] = self.escape_code(val1 or val2)
self.append_node(parsetree.Tag, keyword, attributes)
if isend:
self.tag.pop()
......
......@@ -79,6 +79,23 @@ class EncodingTest(unittest.TestCase):
""".encode('utf-8'))
assert template.render_unicode().strip() == u"""hi, drôle de petit voix m’a réveillé."""
def test_unicode_literal_in_def(self):
template = Template(u"""## -*- coding: utf-8 -*-
<%def name="bello(foo, bar)">
Foo: ${ foo }
Bar: ${ bar }
</%def>
<%call expr="bello(foo=u'árvíztűrő tükörfúrógép', bar=u'ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP')">
</%call>""".encode('utf-8'))
assert flatten_result(template.render_unicode()) == u"""Foo: árvíztűrő tükörfúrógép Bar: ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP"""
template = Template(u"""## -*- coding: utf-8 -*-
<%def name="hello(foo=u'árvíztűrő tükörfúrógép', bar=u'ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP')">
Foo: ${ foo }
Bar: ${ bar }
</%def>
${ hello() }""".encode('utf-8'))
assert flatten_result(template.render_unicode()) == u"""Foo: árvíztűrő tükörfúrógép Bar: ÁRVÍZTŰRŐ TÜKÖRFÚRÓGÉP"""
def test_input_encoding(self):
"""test the 'input_encoding' flag on Template, and that unicode objects arent double-decoded"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment