# HG changeset patch # User cmlenz # Date 1158167970 0 # Node ID c7dd64bcde9c10570272056d50c8c9cee037c2b6 # Parent b92a3648b9c185659e8ddbb44733d5871bd13195 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."""