[英]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. 我没有轻松访问代码,我只使用Mako模板,我想知道模板可用的所有值,我可以使用。
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 .' 关于Mako Runtime环境的整个部分可能值得一读,特别是“ 所有内置名称 ”部分。 You may find the other post I just made relevant:
您可能会找到我刚才提到的另一篇文章:
Mako how to check if variable exists or not. Mako如何检查变量是否存在。
让我们尝试这个我认为这必须有所帮助:
${globals()}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.