Mercurial > genshi > mirror
changeset 246:c7dd64bcde9c trunk
Document that `#end` markers in text templates can be used as comments.
author | cmlenz |
---|---|
date | Wed, 13 Sep 2006 17:19:30 +0000 |
parents | b92a3648b9c1 |
children | cf4a125b44a1 |
files | doc/text-templates.txt genshi/tests/template.py |
diffstat | 2 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/doc/text-templates.txt +++ b/doc/text-templates.txt @@ -121,7 +121,10 @@ Directives must be on separate lines, and the ``#`` character must be be the first non-whitespace character on that line. Each directive must be “closed” -using a ``#end`` marker. +using a ``#end`` marker. You can add after the ``#end`` marker, for example to +document which directive is being closed, or even the expression associated with +that directive. Any text after ``#end`` (but on the same line) is ignored, +and effectively treated as a comment. If you want to include a literal ``#`` in the output, you need to escape it by prepending a backslash character (``\``). Note that this is **not** required
--- a/genshi/tests/template.py +++ b/genshi/tests/template.py @@ -996,6 +996,13 @@ tmpl = TextTemplate('\\## escaped comment') self.assertEqual('## escaped comment', str(tmpl.generate())) + def test_end_with_args(self): + tmpl = TextTemplate(""" + #if foo + bar + #end 'if foo'""") + self.assertEqual('', str(tmpl.generate())) + class TemplateLoaderTestCase(unittest.TestCase): """Tests for the template loader."""