]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Filter out `None` from parsed blocks
authorKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 20:30:58 +0000 (16:30 -0400)
committerKevin <kevin@kevin-brown.com>
Sun, 10 May 2020 20:30:58 +0000 (16:30 -0400)
This allows for comments to not appear in the generated AST.

new_parser.py

index fbaac6eb56eca98c1289bcb377f1cfcc83f90f02..0d1aa79e43bc3553507713185fac2ccada38bfda 100644 (file)
@@ -6,7 +6,8 @@ def lineno_from_parseinfo(parseinfo):
 \r
 def parse(ast):\r
     if isinstance(ast, list):\r
-        return [parse(item) for item in ast]\r
+        nodes = (parse(item) for item in ast)\r
+        return [node for node in nodes if node is not None]\r
 \r
     if isinstance(ast, str):\r
         return parse_output(ast)\r