if it is a styling problem, you can do that with javascript, after all, the 
a link with href == document.location it's the active link.

if it's a "optimize my python code" you're going to cycle fully the 
response.menu list with that method. if the active page is the first on the 
list, you could skip checking the subsequent elements

active = None
for el in response.menu:
     if el[1]:
        active = el
        break

Maybe the execution time will reduce a little, but I don't think you'll 
gain many ms on small lists like the one on the menu.

Il giorno sabato 19 maggio 2012 14:22:23 UTC+2, François Delpierre ha 
scritto:
>
> Hi,
>
> Here is my solution :
> If my response.menu is somthing like :
>
> response.menu = [('Menu1', False), ('Menu2', True), ('Menu3', False)]
>
> I can use this in my view to display the active menu :
> {{=[x[0] for x in response.menu if x[1]==True][0]}}
>
>
> It's working well, but is there no better and more efficient way ?
>
> Thanks,
>

Reply via email to