Permalink
Browse files

Merge pull request #1 from ysugiura/master

Changed 'wikify_content' template tag to support 'as var_name" style options.
  • Loading branch information...
2 parents d7e0578 + 339f3f1 commit b6b9e0df2bb86942e4346eeaad8557e8aaf56e8a @paltman paltman committed Oct 8, 2011
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 b6b9e0d

Please sign in to comment.