]> git.ipfire.org Git - thirdparty/tornado.git/commitdiff
Support "from x import y" in templates, not just "import x"
authorBen Darnell <ben@bendarnell.com>
Mon, 8 Nov 2010 18:49:03 +0000 (10:49 -0800)
committerBen Darnell <ben@bendarnell.com>
Mon, 8 Nov 2010 18:49:03 +0000 (10:49 -0800)
tornado/template.py

index 14cb967e2da81350b96a9a3882654e8add6461bf..5cc5e00341ec455e3aeb7e03bea90560887da7db 100644 (file)
@@ -532,7 +532,8 @@ def _parse(reader, in_block=None):
                 raise ParseError("Extra {%% end %%} block on line %d" % line)
             return body
 
-        elif operator in ("extends", "include", "set", "import", "comment"):
+        elif operator in ("extends", "include", "set", "import", "from",
+                          "comment"):
             if operator == "comment":
                 continue
             if operator == "extends":
@@ -540,7 +541,7 @@ def _parse(reader, in_block=None):
                 if not suffix:
                     raise ParseError("extends missing file path on line %d" % line)
                 block = _ExtendsBlock(suffix)
-            elif operator == "import":
+            elif operator in ("import", "from"):
                 if not suffix:
                     raise ParseError("import missing statement on line %d" % line)
                 block = _Statement(contents)