X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/41e79f5deff58b34f185c8c7426f505793c1d9c7..02b46ac5bb9ae5301e4764b9c111c971aa86b333:/apps/catalogue/templatetags/switch_tag.py diff --git a/apps/catalogue/templatetags/switch_tag.py b/apps/catalogue/templatetags/switch_tag.py index b91f872a4..72476bef0 100644 --- a/apps/catalogue/templatetags/switch_tag.py +++ b/apps/catalogue/templatetags/switch_tag.py @@ -1,11 +1,11 @@ # Source: http://djangosnippets.org/snippets/967/ # Author: adurdin # Posted: August 13, 2008 -# -# +# +# # We can use it based on djangosnippets Terms of Service: # (http://djangosnippets.org/about/tos/) -# +# # 2. That you grant any third party who sees the code you post # a royalty-free, non-exclusive license to copy and distribute that code # and to make and distribute derivative works based on that code. You may @@ -71,13 +71,13 @@ def do_switch(parser, token): got_else = False while token.contents != 'endswitch': nodelist = parser.parse(BlockTagList('case', 'else', 'endswitch')) - + if got_else: raise template.TemplateSyntaxError("'else' must be last tag in '%s'." % tag_name) contents = token.contents.split() token_name, token_args = contents[0], contents[1:] - + if token_name == 'case': tests = map(parser.compile_filter, token_args) case = (tests, nodelist) @@ -122,7 +122,7 @@ class SwitchNode(Node): except VariableDoesNotExist: no_value = True value_missing = None - + for tests, nodelist in self.cases: if tests is None: return nodelist.render(context)