Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updated variable name to avoid complaints about names starting with _

  • Loading branch information...
commit b679b1ddc5be3fed51e4b42d0923566ffb9c1cec 1 parent d27dd95
@kennethlove authored
Showing with 14 additions and 14 deletions.
  1. +14 −14 tabs/templatetags/tabs.py
View
28 tabs/templatetags/tabs.py
@@ -2,10 +2,10 @@
register = template.Library()
-ACTIVE_TAB_NAME = '_ACTIVETABS'
+ACTIVE_TAB_NAME = 'ACTIVETABS'
DEFAULT_NAMESPACE = 'default'
-def get_active_tabs(context):
+def get_active_tabs(context):
active_tabs = template.Variable(ACTIVE_TAB_NAME)
try:
return active_tabs.resolve(context)
@@ -16,23 +16,23 @@ def set_active_tab(context, namespace, name):
active_tabs = get_active_tabs(context)
active_tabs[namespace] = name
context[ACTIVE_TAB_NAME] = active_tabs
-
+
def is_active_tab(context, namespace, name):
active_tabs = get_active_tabs(context)
if namespace in active_tabs and active_tabs[namespace]==name:
return True
return False
-
+
class ActiveTabNode(template.Node):
-
+
def __init__(self, name, namespace=None):
if namespace is None:
namespace = DEFAULT_NAMESPACE
self.namespace = template.Variable(namespace)
self.name = template.Variable(name)
-
+
def render(self, context):
try:
namespace = self.namespace.resolve(context)
@@ -50,13 +50,13 @@ class IfActiveTabNode(template.Node):
def __init__(self, nodelist_true, nodelist_false, name, namespace=None):
if namespace is None:
namespace = DEFAULT_NAMESPACE
-
+
self.namespace = template.Variable(namespace)
self.name = template.Variable(name)
-
+
self.nodelist_true = nodelist_true
self.nodelist_false = nodelist_false
-
+
def render(self, context):
try:
namespace = self.namespace.resolve(context)
@@ -66,7 +66,7 @@ def render(self, context):
name = self.name.resolve(context)
except template.VariableDoesNotExist(context):
name = None
-
+
if is_active_tab(context, namespace, name):
return self.nodelist_true.render(context)
return self.nodelist_false.render(context)
@@ -81,7 +81,7 @@ def activetab(parser, token):
else:
namespace = bits[0]
name = bits[1]
-
+
return ActiveTabNode(name, namespace)
activetab = register.tag('activetab', activetab)
@@ -105,6 +105,6 @@ def ifactivetab(parser, token):
return IfActiveTabNode(nodelist_true, nodelist_false, name, namespace)
ifactivetab = register.tag('ifactivetab', ifactivetab)
-
-
-
+
+
+
Please sign in to comment.
Something went wrong with that request. Please try again.