Mercurial > genshi > mirror
diff markup/tests/template.py @ 154:8bd5c8cd33e0 trunk
* Make sure `py:def` macros don't go out of scope if they are defined inside another directive.
* Cleaned up the `DefDirective` implementation a bit.
author | cmlenz |
---|---|
date | Wed, 16 Aug 2006 14:04:30 +0000 |
parents | cdb2a1f930e2 |
children | 3f23fafeef99 |
line wrap: on
line diff
--- a/markup/tests/template.py +++ b/markup/tests/template.py @@ -185,6 +185,24 @@ <b>foo</b> </doc>""", str(tmpl.generate())) + def test_nested_defs(self): + """ + Verify that a template function defined inside a conditional block can + be called from outside that block. + """ + tmpl = Template("""<doc xmlns:py="http://markup.edgewall.org/"> + <py:if test="semantic"> + <strong py:def="echo(what)">${what}</strong> + </py:if> + <py:if test="not semantic"> + <b py:def="echo(what)">${what}</b> + </py:if> + ${echo('foo')} + </doc>""") + self.assertEqual("""<doc> + <strong>foo</strong> + </doc>""", str(tmpl.generate(semantic=True))) + class ForDirectiveTestCase(unittest.TestCase): """Tests for the `py:for` template directive."""