Opened 17 years ago
Closed 13 years ago
#6691 closed New feature (fixed)
Make it possible for template loaders to optionally return compiled Template object
Reported by: | redvasily | Owned by: | nobody |
---|---|---|---|
Component: | Template system | Version: | dev |
Severity: | Normal | Keywords: | |
Cc: | redvasily@…, jefferya@… | Triage Stage: | Design decision needed |
Has patch: | yes | Needs documentation: | yes |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description (last modified by )
Django now uses two stage template loading process:
This patch follows our (very) small discussion on mailing list: http://groups.google.ru/group/django-developers/browse_thread/thread/5e54ab5cac98da90?hl=en
- First find_template_source() which uses settings.TEMPLATE_LOADERS to actually load template
- get_template_from_string() which is essentially a factory function for Template objects
I modified django.template.loader.find_template_source() function and renamed it to find_template() to check if return value of template loader is a tuple - if it's a tuple than standard it proceeds with standard template loading process:
origin = make_origin(display_name, loader, name, dirs) template = Template(template, origin, name)
But if it fails to unpack return value of template loader it assumes that template loader returned compiled template object and returns it.
This change is backwards compatible and opens a lot of new possibilities for template system.
Attachments (1)
Change History (7)
by , 17 years ago
Attachment: | templateloader.diff added |
---|
comment:1 by , 16 years ago
Cc: | added |
---|
comment:2 by , 16 years ago
Description: | modified (diff) |
---|
comment:3 by , 16 years ago
Needs documentation: | set |
---|---|
Triage Stage: | Unreviewed → Design decision needed |
comment:4 by , 14 years ago
Type: | → New feature |
---|
comment:5 by , 13 years ago
Severity: | → Normal |
---|
comment:6 by , 13 years ago
Easy pickings: | unset |
---|---|
Resolution: | → fixed |
Status: | new → closed |
UI/UX: | unset |
This was fixed my Mike Malone's cache template loader patch that went in a while ago.
Diff implementing this ticket