Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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)?

like image 442
Jānis Elmeris Avatar asked Jan 17 '23 15:01

Jānis Elmeris


1 Answers

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.

like image 73
chris Avatar answered Jan 25 '23 19:01

chris