From: J. Cliff Dyer Date: Thu, 3 Dec 2009 16:21:25 +0000 (-0500) Subject: Recent commit broke parsing of zero arg syntax. (i.e. {% analytics %} and {% analyt... X-Git-Url: https://git.parisson.com/?a=commitdiff_plain;h=6dc2dcd028c29f927cc3927a692d08689c2a024b;p=django-google-tools.git Recent commit broke parsing of zero arg syntax. (i.e. {% analytics %} and {% analytics_async %}). --- diff --git a/google_analytics/templatetags/analytics.py b/google_analytics/templatetags/analytics.py index f49eb36..ae6fe44 100644 --- a/google_analytics/templatetags/analytics.py +++ b/google_analytics/templatetags/analytics.py @@ -9,13 +9,17 @@ register = template.Library() Analytics = models.get_model('googleanalytics', 'analytics') def do_get_analytics(parser, token): - try: + contents = token.split_contents() + tag_name = contents[0] + template_name = 'google_analytics/%s_template.html' % tag_name + if len(contents) == 2: # split_contents() knows not to split quoted strings. - tag_name, code = token.split_contents() - except ValueError: + code = contents[1] + elif len(contents) == 1: code = None + else: + raise template.TemplateSyntaxError, "%r cannot take more than one argument" % tag_name - template_name = 'google_analytics/%s_template.html' % tag_name if not code: current_site = Site.objects.get_current() else: @@ -23,6 +27,7 @@ def do_get_analytics(parser, token): raise template.TemplateSyntaxError, "%r tag's argument should be in quotes" % tag_name code = code[1:-1] current_site = None + return AnalyticsNode(current_site, code, template_name) class AnalyticsNode(template.Node):