Skip to content

Commit 0302588

Browse files
author
Tom
committed
Don't call show_feature if context key is invalid
1 parent dd448af commit 0302588

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

feature_flipper/templatetags/feature_flipper.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ def render(self, context):
4343
"""
4444
user = self._get_value(self.user_key, context)
4545
feature = self._get_value(self.feature, context)
46-
allowed = show_feature(user, feature)
4746

47+
if feature is None:
48+
return ''
49+
50+
allowed = show_feature(user, feature)
4851
return self.nodelist.render(context) if allowed else ''
4952

5053
def _get_value(self, key, context):
@@ -57,4 +60,4 @@ def _get_value(self, key, context):
5760
return key[1:-1]
5861
if key in string.digits:
5962
return int(key)
60-
return context.get(key, False)
63+
return context.get(key, None)

0 commit comments

Comments
 (0)