# HG changeset patch # User cmlenz # Date 1158167970 0 # Node ID 6fc4edebe12c0c9ddb890a69c84b4492c24a40d4 # Parent 2baac3afa66e92f59347c5f9b5f702fd431bd114 Document that `#end` markers in text templates can be used as comments. diff --git a/doc/text-templates.txt b/doc/text-templates.txt --- 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 diff --git a/genshi/tests/template.py b/genshi/tests/template.py --- 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."""