diff options
| author | Russell Keith-Magee <russell@keith-magee.com> | 2006-08-27 12:35:07 +0000 |
|---|---|---|
| committer | Russell Keith-Magee <russell@keith-magee.com> | 2006-08-27 12:35:07 +0000 |
| commit | 89fa97b8374131614698bbab1544f9bdafdb66bd (patch) | |
| tree | 4c2af52d9fb5d45a24c4dea6ac63d647e7f147c1 /django/template/__init__.py | |
| parent | 7dce86ce0220ffb9f3f579cbd1e881e988764c9d (diff) | |
Refs #2333 - Added a signal that is emitted whenever a template is rendered, and added a 'name' field to Template to allow easy identification of templates.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@3659 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'django/template/__init__.py')
| -rw-r--r-- | django/template/__init__.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/django/template/__init__.py b/django/template/__init__.py index ba7ca4c02b..2f68924d18 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -60,6 +60,8 @@ from django.conf import settings from django.template.context import Context, RequestContext, ContextPopException from django.utils.functional import curry from django.utils.text import smart_split +from django.dispatch import dispatcher +from django.template import signals __all__ = ('Template', 'Context', 'RequestContext', 'compile_string') @@ -137,13 +139,14 @@ class StringOrigin(Origin): return self.source class Template(object): - def __init__(self, template_string, origin=None): + def __init__(self, template_string, origin=None, name='<Unknown Template>'): "Compilation stage" if settings.TEMPLATE_DEBUG and origin == None: origin = StringOrigin(template_string) # Could do some crazy stack-frame stuff to record where this string # came from... self.nodelist = compile_string(template_string, origin) + self.name = name def __iter__(self): for node in self.nodelist: @@ -152,6 +155,7 @@ class Template(object): def render(self, context): "Display stage -- can be called many times" + dispatcher.send(signal=signals.template_rendered, sender=self, template=self, context=context) return self.nodelist.render(context) def compile_string(template_string, origin): |
