All pastes #77094 Raw Edit

Diff

public text v1 · immutable
·published 2006-07-02 16:49 UTC
rendered paste body
Index: markup/plugin.py===================================================================--- markup/plugin.py	(revision 34)+++ markup/plugin.py	(working copy)@@ -20,7 +20,19 @@ from pkg_resources import resource_filename  from markup.template import Context, Template, TemplateLoader+from markup.core import Stream, QName +def ET(element):+    yield (Stream.START, (QName(element.tag), element.items()),+           ('<string>', 0, 0))+    if element.text:+        yield Stream.TEXT, element.text, ('<string>', 0, 0)+    for child in element.getchildren():+        for item in ET(child):+            yield item+    yield Stream.END, QName(element.tag), ('<string>', 0, 0)+    if element.tail:+        yield Stream.TEXT, element.tail, ('<string>', 0, 0)  class TemplateEnginePlugin(object):     """Implementation of the plugin API."""@@ -53,7 +65,7 @@         if not isinstance(template, Template):             template = self.load_template(template) -        data = {}+        data = {'ET': ET}         if self.get_extra_vars:             data.update(self.get_extra_vars())         data.update(info)