I would like to style the active menu item, to do this i need to compare the current url agains a route. I know that I can do this in javascript, but I was wondering how other people have solved this in play.
Any suggestions?
Pseudocode:
<a #{routeIsActive Application.index()} class="active"#{/if} href="@{Application.index()}">My Page</a>
Unfortunately, I couldn’t find an easy way to do this. The simplest solution I could find was to write a fast tag (but this may be due to my lack of Groovy experience).
I got this working with this code.
In your View
Then, create a new FastTag for activeRoute
Make sure you add the relevant imports.
This allows you to specify an active and inactive class, which is a little more than you requested