Referenced templates from a template

Skip to first unread message

J Lorieau

Jul 4, 2018, 8:30:41 AM7/4/18
to pocoo-libs
Dear Pocoo team,

I would like to get a list of all parent template paths for a template loaded from a file system that includes parent (inherited) templates. I am using the standard approach described in the documentation by preparing loaders and an environment to generate a template object, which I then use to render the final string. The source includes a "find_referenced_templates" in the Meta submodule to do exactly what I'm seeking from an AST, but I could not find a way to generate an AST from an environment.Template object.

How would I go about getting a list of parent templates for a loaded template from the environment?

I've also posted this question on SO with a slightly more detailed explanation ( 

As a feature request, I suggest adding a 'parent_filenames' attribute to the environment.Template object to get a list of all parent template filenames. This would be a useful complementary to the 'filename' attribute of the template object. Alternative (or additionally), a 'get_ast' method in the environment.Template object would be helpful as well.

Thank you,

Reply all
Reply to author
0 new messages