diff markup/output.py @ 89:80386d62814f trunk

Support comments in templates that are not included in the output, in the same way Kid does: if the comment text starts with a `!` character, it is stripped from the output.
author cmlenz
date Mon, 17 Jul 2006 23:10:35 +0000
parents 4938c310d904
children fa08aef181a2
line wrap: on
line diff
--- a/markup/output.py
+++ b/markup/output.py
@@ -22,7 +22,7 @@
 from itertools import chain
 
 from markup.core import escape, Markup, Namespace, QName
-from markup.core import DOCTYPE, START, END, START_NS, END_NS, TEXT
+from markup.core import DOCTYPE, START, END, START_NS, END_NS, TEXT, COMMENT
 
 __all__ = ['Serializer', 'XMLSerializer', 'HTMLSerializer']
 
@@ -151,6 +151,9 @@
             elif kind is TEXT:
                 yield escape(data, quotes=False)
 
+            elif kind is COMMENT:
+                yield Markup('<!--%s-->' % data)
+
 
 class HTMLSerializer(Serializer):
     """Produces HTML text from an event stream.
@@ -237,6 +240,9 @@
             elif kind is TEXT:
                 yield escape(data, quotes=False)
 
+            elif kind is COMMENT:
+                yield Markup('<!--%s-->' % data)
+
 
 class _PushbackIterator(object):
     """A simple wrapper for iterators that allows pushing items back on the
Copyright (C) 2012-2017 Edgewall Software