mako icon indicating copy to clipboard operation
mako copied to clipboard

[feature] List all filenames used in render()

Open jcpunk opened this issue 6 years ago • 3 comments

I've got a fairly complex template layout. It would be helpful for debugging to have a way I could see which filenames are part of a template.

Example: example.tmpl includes two template files : included_filename1.tmpl included_filename2.tmpl

lookup = mako.lookup.TemplateLookup(directories='/my/directory')
template = lookup.get_template('example.tmpl')

If the template object supported something like source_files that provided ['example.tmpl', 'included_filename1.tmpl', 'included_filename2.tmpl'] that would dramatically simplify my debugging down the line.

jcpunk avatar Jul 08 '19 14:07 jcpunk

I can accept PRs that achieve this as long as they include tests.

zzzeek avatar Jul 31 '19 19:07 zzzeek

This feature is very similar to what I'm looking for. My use case is the following: I have a website with hundreds of pages. I build the website with make. To increase build speed I'd like to generate dependencies (very common strategy in make projects). I would love to be able to list the immediate dependencies of a template (parent template, includes, namespace files, etc)

@zzzeek, how big of an effort do you think it would be to create this type of PR (including tests)?

aioobe avatar Dec 14 '19 02:12 aioobe

both of these things can be done in the interim as separate utilities. use the Lexer to get a template structure, then traverse it to locate filenames and whatever. it would be cleaner just as a separate utility function given a Template or a filename.

zzzeek avatar Dec 14 '19 15:12 zzzeek