Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Play Framework 2.0 Find the current action in a view

In a Play Framework 2.0 app, I would like to be able to specify a CSS class for the active page. How do I that?

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

Specifically, what do I put in the if statement?

like image 695
Ryan Avatar asked Aug 01 '12 20:08

Ryan


1 Answers

@request.uri works at least with play framework 2 to see more read 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..
}
like image 195
Mauno Vähä Avatar answered Nov 16 '22 15:11

Mauno Vähä