From: Ben Darnell Date: Sun, 14 Feb 2016 03:30:50 +0000 (-0500) Subject: Document and test `{#!` syntax. X-Git-Tag: v4.4.0b1~48 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7b61d9ea716cbd4b426e91dbdb34362b34a69b5b;p=thirdparty%2Ftornado.git Document and test `{#!` syntax. Fixes #1606 --- diff --git a/tornado/template.py b/tornado/template.py index c7f26eff7..499cc242c 100644 --- a/tornado/template.py +++ b/tornado/template.py @@ -94,12 +94,15 @@ Syntax Reference Template expressions are surrounded by double curly braces: ``{{ ... }}``. The contents may be any python expression, which will be escaped according to the current autoescape setting and inserted into the output. Other -template directives use ``{% %}``. These tags may be escaped as ``{{!`` -and ``{%!`` if you need to include a literal ``{{`` or ``{%`` in the output. +template directives use ``{% %}``. To comment out a section so that it is omitted from the output, surround it with ``{# ... #}``. +These tags may be escaped as ``{{!``, ``{%!``, and ``{#!`` +if you need to include a literal ``{{``, ``{%``, or ``{#`` in the output. + + ``{% apply *function* %}...{% end %}`` Applies a function to the output of all template code between ``apply`` and ``end``:: diff --git a/tornado/test/template_test.py b/tornado/test/template_test.py index 7b21ce754..ad5ac71ef 100644 --- a/tornado/test/template_test.py +++ b/tornado/test/template_test.py @@ -67,6 +67,7 @@ class TemplateTest(unittest.TestCase): self.assertRaises(ParseError, lambda: Template("{%")) self.assertEqual(Template("{{!").generate(), b"{{") self.assertEqual(Template("{%!").generate(), b"{%") + self.assertEqual(Template("{#!").generate(), b"{#") self.assertEqual(Template("{{ 'expr' }} {{!jquery expr}}").generate(), b"expr {{jquery expr}}")