-
-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support comprehensions inside functions when use strict_undefined flag.
Fixes: #320 Now the test code works as expected if strict_undefined is set to true: ```python from mako.template import Template text = """ <% mydict = { 'foo': 1 } ## Uncomment the following line to workaround the error ##k = None def getkeys(x): return [ k for k in x.keys() ] %> ${ ','.join( getkeys(mydict) ) } """ tmpl = Template(text=text, strict_undefined=True) out = tmpl.render() print(out) ``` output: ``` foo ``` Closes: #386 Pull-request: #386 Pull-request-sha: cc6a3e0 Change-Id: I0591873a83837f8f35b0963c0536df1e2675012f
- Loading branch information
Showing
4 changed files
with
124 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
.. change:: | ||
:tags: bug, parser | ||
:tickets: 320 | ||
|
||
Fixed unexpected syntax error in strict_undefined mode that occurred | ||
when using comprehensions within a function in a Mako Python code block. | ||
Now, the local variable in comprehensions won't be added to the checklist | ||
when using strict_undefined mode. | ||
Pull request courtesy Hai Zhu. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters