Permalink
Browse files

Changed 'wikify_content' template tag to support 'as var_name" style

options.
  • Loading branch information...
1 parent dedfb86 commit 339f3f16104d18e2d7f62e154d88118123119ca5 Yuichiro Sugiura committed Nov 29, 2010
Showing with 13 additions and 4 deletions.
  1. +13 −4 src/wakawaka/templatetags/wakawaka_tags.py
@@ -45,14 +45,19 @@ def wikify(value):
class WikifyContentNode(Node):
- def __init__(self, content_expr, group_var):
+ def __init__(self, content_expr, group_var, var_name):
self.content_expr = content_expr
self.group_var = Variable(group_var)
-
+ self.var_name = var_name
+
def render(self, context):
content = self.content_expr.resolve(context)
group = self.group_var.resolve(context)
- return replace_wikiwords(content, group)
+ if self.var_name:
+ context[self.var_name] = replace_wikiwords(content, group)
+ return ''
+ else:
+ return replace_wikiwords(content, group)
@register.tag
def wikify_content(parser, token):
@@ -61,4 +66,8 @@ def wikify_content(parser, token):
group_var = bits[2]
except IndexError:
group_var = None
- return WikifyContentNode(parser.compile_filter(bits[1]), group_var)
+ if bits[-2] == 'as':
+ var_name = bits[-1]
+ else:
+ var_name = ''
+ return WikifyContentNode(parser.compile_filter(bits[1]), group_var, var_name)

0 comments on commit 339f3f1

Please sign in to comment.