Hi,

Javier Rojas wrote:
> Hi all,
> 
> I want to write a script that allows me to pass it a template and a
> config file, and that fills the template with the data provided in the
> config. file. However  I'd like that, if there are any undefined
> variables in the template, the scripts asks me for them interactively.
> 
> I was considering 2 approaches:
> 
>   1. somehow get a list of all the variables inside a template, and ask
>      only those not specified on the config. file. 
I would propose that one.  Because you have a dict of the already known
variables anyways I would traverse the AST.  The AST however changed
from Jinja 1.0 to 1.2 so you would have to required the most recent
version.  The current AST is final and interfaced by at least one
application, albeit undocumented.

If you call ``jinja_environment.parse('template sourcecode')``
you get back a `Template` node which you can then traverse for the
`NameExpression` nodes which represent variable names.  The only thing
you have to make sure it to exclude name nodes returned that are in fact
assignments to those nodes.

> checking the docs. I can't find a proper way to get the info needed for
> (1.), and trying (2.) doesn't seem to yield any useful info. about the
> name of the missing var. Any hints to do this?
> 
> NOTE: please cc me any answer, since I'm not on the mail list
Done, didn't know that the list was open ^^

> Thanks in advance,
Regards,
Armin


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pocoo-libs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pocoo-libs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to