Play Framework 2.0 Find the current action in the view

In a Play Framework 2.0 application, I would like to specify a CSS class for the active page. How to do it?

<li @if( ) { class="active" }> 
  <a href="@routes.Application.index()"> Home </a> 
</li>

In particular, what do I insert in an if statement?

+5
source share
1 answer

@ request.uri works with at least framework 2 to see more http://www.playframework.org/documentation/api/2.0/java/play/mvc/Http.Request.html

Edit: you can try this for example ..

@if(request.uri.contains("home")){ 
  ..home word in url..
} else {
  ..home word not in url..
}
+7
source

All Articles