## helpers.py # Mark as active helper def mark_as_active_section(col, current_section): def mark_as_active(item, current_section): if current_section.startswith(item['id']): item['active'] = True return item return map(lambda i: mark_as_active(i, current_section),col) # Is section decorator def is_section(func): def section_marker(*args, **kwargs): if kwargs['menu']: kwargs['menu'] = mark_as_active_section(kwargs['menu'], func.__name__) return func(*args, **kwargs) return section_marker ## urls.py # Static Menu menu = lambda: [ {'id':'home','title':'Home','active':False,'href':'/home/'}, ... ] urlpatterns = patterns('', (r'^home/$', main_views.home, {'menu':menu()}), ... ) ## views.py from helpers import is_section @is_section def home(request, menu): context = Context({'menu':menu,...}) ... ## templates/start.html {% for section in menu %}