X-Git-Url: https://git.mdrn.pl/wolnelektury.git/blobdiff_plain/357027375ff8867f42ca34bcbfb5a78b5b185fc3..190a12c5524f533a5fa74569575cccf22f745847:/src/wolnelektury/templatetags/switch_tag.py diff --git a/src/wolnelektury/templatetags/switch_tag.py b/src/wolnelektury/templatetags/switch_tag.py index 72476bef0..d4701ab7e 100644 --- a/src/wolnelektury/templatetags/switch_tag.py +++ b/src/wolnelektury/templatetags/switch_tag.py @@ -58,6 +58,7 @@ def do_switch(parser, token): # of Parser.parse() relating to the "parse_until" argument. def __init__(self, *names): self.names = set(names) + def __contains__(self, token_contents): name = token_contents.split()[0] return name in self.names @@ -94,6 +95,7 @@ def do_switch(parser, token): return SwitchNode(variable, cases) + class SwitchNode(Node): def __init__(self, variable, cases): self.variable = variable @@ -122,6 +124,7 @@ class SwitchNode(Node): except VariableDoesNotExist: no_value = True value_missing = None + value = None for tests, nodelist in self.cases: if tests is None: