You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We use Jinja private methods and they have changed their signature. My goal with this command is to get a sense of where templates are being loaded from. I was able to hack together this:
@dev_command.command('templates', short_help=_('Show paths searched for a template.'))@flask.cli.with_appcontextdeftemplates_command():
app=flask.current_apphave_loaders= [app] + [bpforbpinapp.iter_blueprints() ifbp.jinja_loader]
result=defaultdict(list)
forapp_or_bpinhave_loaders:
jinja_loader=app_or_bp.jinja_loaderifhasattr(jinja_loader, 'loaders'):
# ChoiceLoader has a list of loadersloaders=jinja_loader.loaderselse:
loaders= [jinja_loader]
forloaderinloaders:
# PackageLoaderifhasattr(loader, '_template_root'):
result[app_or_bp.name].append(loader._template_root)
else:
# FileSystemLoaderresult[app_or_bp.name].append(loader.searchpath)
forsource_nameinsorted(result.keys()):
#search_paths = sorted(result[source_name])click.echo(source_name)
forroot_pathinresult[source_name]:
click.echo(' {}'.format(root_path))
I think the old command would have told you every template and where it was being loaded from. That's helpful, but when you have a blueprint (or something) with a loader mis-configured, it won't actually find the template and so it won't be listed with the old command. The above command actually lists the loaders and where they are sourcing templates from, which helps identify mis-configured loaders, which is what I think I really care about.
The text was updated successfully, but these errors were encountered:
We use Jinja private methods and they have changed their signature. My goal with this command is to get a sense of where templates are being loaded from. I was able to hack together this:
I think the old command would have told you every template and where it was being loaded from. That's helpful, but when you have a blueprint (or something) with a loader mis-configured, it won't actually find the template and so it won't be listed with the old command. The above command actually lists the loaders and where they are sourcing templates from, which helps identify mis-configured loaders, which is what I think I really care about.
The text was updated successfully, but these errors were encountered: