Is it possible to get variable names in a Mako template before rendering?
from mako.template import Template
bar = Template("${foo}")
Use Case:
We have configuration files in which we specify metadata from the database that will be displayed on the web page. A client can select one of several hundred different pieces of named metadata. There are N slots that the client can configure, but we do not know in advance which pieces of metadata that a particular client would like to fill out on the form. Because if this is when visualizing the form, we need to know in advance what variable names we need to pass for this client template.
We thought that you have a consistent dictionary with all possible values and this is transmitted at every moment of time, but it was inoperative, since new available fields are often added to the base pool of available metadata that the client could select.
Because of this, we hoped to use Mako to create template configuration files, but I cannot figure out how to determine using the field values in the template so that I can create a fully formed Context to go to the template.
source
share