Mercurial > genshi > mirror
changeset 75:3722696d0343 trunk
Empty attributes in templates were being stripped out. Thanks to Jonas for the patch.
author | cmlenz |
---|---|
date | Wed, 12 Jul 2006 21:27:30 +0000 |
parents | d54b5fd60b52 |
children | 85f70ec37112 |
files | markup/template.py markup/tests/template.py |
diffstat | 2 files changed, 10 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/markup/template.py +++ b/markup/template.py @@ -717,7 +717,10 @@ raise BadDirectiveError(name, pos[0], pos[1]) directives.append(cls(value)) else: - value = list(self._interpolate(value, *pos)) + if value: + value = list(self._interpolate(value, *pos)) + else: + value = [(TEXT, u'', pos)] new_attrib.append((name, value)) if directives:
--- a/markup/tests/template.py +++ b/markup/tests/template.py @@ -417,9 +417,12 @@ self.assertEqual('<root> 42 42</root>', str(tmpl.generate(ctxt))) def test_interpolate_non_string_attrs(self): - ctxt = Context() tmpl = Template('<root attr="${1}"/>') - self.assertEqual('<root attr="1"/>', str(tmpl.generate(ctxt))) + self.assertEqual('<root attr="1"/>', str(tmpl.generate())) + + def test_empty_attr(self): + tmpl = Template('<root attr=""/>') + self.assertEqual('<root attr=""/>', str(tmpl.generate())) def test_bad_directive_error(self): xml = '<p xmlns:py="http://markup.edgewall.org/" py:do="nothing" />' @@ -434,7 +437,7 @@ xml = '<p xmlns:py="http://markup.edgewall.org/" py:if="bar\'" />' tmpl = Template(xml, filename='test.html') try: - list(tmpl.generate(Context())) + list(tmpl.generate()) self.fail('Expected SyntaxError') except TemplateSyntaxError, e: self.assertEqual('test.html', e.filename)