mako icon indicating copy to clipboard operation
mako copied to clipboard

Support comprehensions inside functions when use strict_undefined flag.

Open cocolato opened this issue 1 year ago • 5 comments

Fixes: https://github.com/sqlalchemy/mako/issues/320

Now the test code works as expected if strict_undefined is set to true:

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

cocolato avatar Feb 01 '24 15:02 cocolato

wow I dig this, you're into mako now. great let's run the CI

zzzeek avatar Feb 01 '24 16:02 zzzeek

New Gerrit review created for change daffd3832b4adab291625e1e6efcdb56f8d0d05e: https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5147

sqla-tester avatar Feb 01 '24 16:02 sqla-tester

can you add a changelog file? thanks

zzzeek avatar Feb 05 '24 17:02 zzzeek

All has been updated.

cocolato avatar Feb 06 '24 06:02 cocolato

Patchset cc6a3e0694fb5615db2c3fec2cd23bc9e8a70066 added to existing Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5147

sqla-tester avatar Feb 06 '24 13:02 sqla-tester

Michael Bayer (zzzeek) wrote:

thanks!

View this in Gerrit at https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5147

sqla-tester avatar Apr 03 '24 15:04 sqla-tester

Gerrit review https://gerrit.sqlalchemy.org/c/sqlalchemy/mako/+/5147 has been merged. Congratulations! :)

sqla-tester avatar Apr 03 '24 15:04 sqla-tester