# HG changeset patch # User cmlenz # Date 1156252569 0 # Node ID 181d292eafa2ed62e7fe5a9dbf3040abbb9e97b9 # Parent 1f6ca50287700742adfe5c672d334c0584d0f91a Interpolate multiline expressions in templates. Thanks to Christian Boos for reporting the problem and providing the fix. diff --git a/ChangeLog b/ChangeLog --- a/ChangeLog +++ b/ChangeLog @@ -1,6 +1,6 @@ Version 0.2 http://svn.edgewall.org/repos/markup/tags/0.2.0/ -(?, from branches/stable/0.2.x) +(Aug 22 2006, from branches/stable/0.2.x) * XPath syntax errors now contain position info (ticket #20). * Errors in expression evaluation now contain the correct line number in the @@ -31,6 +31,8 @@ literals before). * XPath expressions in now support XPath variables ($var) in predicates (ticket #31). + * Expressions in templates can now span multiple lines if they are enclosed + in curly braces. Version 0.1 diff --git a/markup/template.py b/markup/template.py --- a/markup/template.py +++ b/markup/template.py @@ -825,7 +825,7 @@ self.stream = stream - _FULL_EXPR_RE = re.compile(r'(? """, str(tmpl.generate(tagname='sayhello'))) + # FIXME + #def test_match_after_step(self): + # tmpl = Template("""
+ # + # Hello ${select('@name')} + # + # + #
""") + # self.assertEqual("""
+ # + # Hello Dude + # + #
""", str(tmpl.generate())) + class StripDirectiveTestCase(unittest.TestCase): """Tests for the `py:strip` template directive.""" @@ -596,6 +610,12 @@ tmpl = Template(' ${var} $var') self.assertEqual(' 42 42', str(tmpl.generate(var=42))) + def test_interpolate_multiline(self): + tmpl = Template("""${dict( + bar = 'baz' + )[foo]}""") + self.assertEqual('baz', str(tmpl.generate(foo='bar'))) + def test_interpolate_non_string_attrs(self): tmpl = Template('') self.assertEqual('', str(tmpl.generate()))