Permalink
Browse files

added captureas tag due to the requirement for translatable notificat…

…ion templates that use the url tag, a.k.a. temporary fix for http://code.djangoproject.com/ticket/7239

git-svn-id: http://django-notification.googlecode.com/svn/trunk@81 590c3fc9-4838-0410-bb95-17a0c9b37ca9
  • Loading branch information...
1 parent 9ccaf61 commit de6231797038c362c28107a90ecb4ebf7bd30494 @jezdez jezdez committed Jul 11, 2008
@@ -1 +1 @@
-{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
+{% load i18n %}{% blocktrans %}{{ notice }}{% endblocktrans %}
No changes.
@@ -0,0 +1,23 @@
+from django import template
+
+register = template.Library()
+
+@register.tag(name='captureas')
+def do_captureas(parser, token):
+ try:
+ tag_name, args = token.contents.split(None, 1)
+ except ValueError:
+ raise template.TemplateSyntaxError("'captureas' node requires a variable name.")
+ nodelist = parser.parse(('endcaptureas',))
+ parser.delete_first_token()
+ return CaptureasNode(nodelist, args)
+
+class CaptureasNode(template.Node):
+ def __init__(self, nodelist, varname):
+ self.nodelist = nodelist
+ self.varname = varname
+
+ def render(self, context):
+ output = self.nodelist.render(context)
+ context[self.varname] = output
+ return ''

0 comments on commit de62317

Please sign in to comment.