]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Allow more than two consecutive curlies to appear in templates (and use
authorBen Darnell <bdarnell@beaker.local>
Thu, 18 Mar 2010 01:48:32 +0000 (18:48 -0700)
committerBen Darnell <bdarnell@beaker.local>
Thu, 18 Mar 2010 01:48:32 +0000 (18:48 -0700)
the innermost).  This was previously a syntax error in the generated python.

tornado/template.py

index eafee778fd378c26c9583ead098600a89351c5e6..b5e94bda702cf09c109a9f63790671f54dce04c4 100644 (file)
@@ -460,6 +460,13 @@ def _parse(reader, in_block=None):
             if reader[curly + 1] not in ("{", "%"):
                 curly += 1
                 continue
+            # When there are more than 2 curlies in a row, use the
+            # innermost ones.  This is useful when generating languages
+            # like latex where curlies are also meaningful
+            if (curly + 2 < reader.remaining() and
+                reader[curly + 1] == '{' and reader[curly + 2] == '{'):
+                curly += 1
+                continue
             break
 
         # Append any text before the special token