comparison markup/template.py @ 89:d4c7617900e3

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 c6f07b7cd3ea
children 242610137d1f
comparison
equal deleted inserted replaced
88:9ecae580dd93 89:d4c7617900e3
24 import posixpath 24 import posixpath
25 import re 25 import re
26 from StringIO import StringIO 26 from StringIO import StringIO
27 27
28 from markup.core import Attributes, Namespace, Stream, StreamEventKind 28 from markup.core import Attributes, Namespace, Stream, StreamEventKind
29 from markup.core import START, END, START_NS, END_NS, TEXT 29 from markup.core import START, END, START_NS, END_NS, TEXT, COMMENT
30 from markup.eval import Expression 30 from markup.eval import Expression
31 from markup.input import XMLParser 31 from markup.input import XMLParser
32 from markup.path import Path 32 from markup.path import Path
33 33
34 __all__ = ['Context', 'BadDirectiveError', 'TemplateError', 34 __all__ = ['Context', 'BadDirectiveError', 'TemplateError',
738 stream[start_offset:] = [(SUB, (directives, substream), 738 stream[start_offset:] = [(SUB, (directives, substream),
739 pos)] 739 pos)]
740 740
741 elif kind is TEXT: 741 elif kind is TEXT:
742 for kind, data, pos in self._interpolate(data, *pos): 742 for kind, data, pos in self._interpolate(data, *pos):
743 stream.append((kind, data, pos))
744
745 elif kind is COMMENT:
746 if not data.lstrip().startswith('!'):
743 stream.append((kind, data, pos)) 747 stream.append((kind, data, pos))
744 748
745 else: 749 else:
746 stream.append((kind, data, pos)) 750 stream.append((kind, data, pos))
747 751
Copyright (C) 2012-2017 Edgewall Software