#15053: Make templates more reusable by Improving template loading algorithm to avoid extending infinite recursion ---------------------------------+---------------------------------------- Reporter: pmartin | Owner: unaizalakain Type: New feature | Status: assigned Component: Template system | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted Has patch: 1 | Needs documentation: 0 Needs tests: 0 | Patch needs improvement: 1 Easy pickings: 0 | UI/UX: 0 ---------------------------------+----------------------------------------
Comment (by prestontimmons): I pushed some more updates to the patch. The template loader api is now simpler and more efficient, thanks to apollo13's suggestions. I'm open to input if this can be simplified even more. '''Loader API''' `get_template_sources` yields all paths the loader will look at for a given template name. This already existed for the filesystem and app loaders. They now also exist for the egg and cached loaders. `get_internal` takes a source argument as returned by `get_template_source` and returns the template contents, or raises `TemplateDoesNotExist` `BaseLoader.get_template` iterates through sources and returns the first matching one, unless a skip argument is passed. The skip argument is a set of sources to ignore. If no template is found, `TemplateDoesNotExist` is raised. The next thing I want to look into is updating the template debug post- mortem message to accurately reflect which templates were skipped or not found. I would also like to improve the message when circular extending happens as well. I checked with Aymeric. He agreed these updates are mostly orthogonal to his recent DEP. I think the main place these would overlap is if `get_template`/`select_template` is updated to also use the `Loader.get_template` api instead of the current `Loader.load_template`. I don't plan to propose any changes to those just yet. -- Ticket URL: <https://code.djangoproject.com/ticket/15053#comment:46> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/065.7f8501c8ea0144c02dcba1b53f46181d%40djangoproject.com. For more options, visit https://groups.google.com/d/optout.