简体   繁体   中英

Output all variables into Mako template

I don't have an easy access to the code, I'm working only with a Mako template, and I would like to know all the values that were made available to the template, which I can use.

Is there a way to add something in the template, so that the output result would contain all the variables (recursively)?

You're looking for the context object . After a minute or two of play:

${context.keys()}    # list of direct variable names
${context.__dict__}  # probably more along what you're looking for.

The entire section on the Mako Runtime environment is probably worth reading, especially the part ' All the built in names .' You may find the other post I just made relevant:

Mako how to check if variable exists or not.

让我们尝试这个我认为这必须有所帮助:

${globals()}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM