FWIW-
I've found the easiest way to handle any elements that have 'active'
items like this, is to create an attribute safe object , Pylons
style :
class TabbedObject(object):
def __getattr__(self, name):
try:
return object.__getattribute__(self,name)
except AttributeError:
return ''
I attach a nav one to my request object, and misc ones for any 'tab'
elements.
request.NavTabs = TabbedObject()
request.NavTabs.home = 'active'
in mako templates, then it's just...
<li class="${request.NavTabs.home}">Home</li>
<li class="${request.NavTabs.about}">About</li>
IIRC, tal allows for conditional attributes
I've decided to stick to this method for a handful of reasons :
- it's been easier to have an 'active' class on projects early-on.
you don't have to write a bunch of custom css for every page
- you can switch around the objects so they spit out entire class tags
if needed, or are based on true/false, etc
- when you deal with tabbed elements or lists, you often end up with
having multiple scenarios on the same page. this is just easy.
--
You received this message because you are subscribed to the Google Groups
"pylons-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/pylons-discuss?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.