Reputation: 4616
I am using the following syntax in the Playframework 2.0 to figure out the given Bootstrap nav li should be active or not, but it doesn't work! Any idea what I missed here?
The following is snippet from my playframework template where I am trying to make Home li as active if the current request path is same as routes index/home
@* Home page is active. *@
<li class=@{"active".when("@request.path" == "@routes.Application.index()")}>
<a href="@routes.Application.index()">Home</a>
</li>
Upvotes: 3
Views: 924
Reputation: 21557
I'm don't know play, but using their template engine in my projects.
How about this way:
@* Home page is active. *@
<li class=@{if (request.path == routes.Application.index().toString()) "active" else ""}>
<a href="@routes.Application.index()">Home</a>
</li>
Upvotes: 2
Reputation: 76
Try this :
<li class="@("active".when(request.path == controllers.routes.Application.index().toString()))">
<a href="@routes.Application.index()">Home</a>
</li>
Upvotes: 1