Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PlayFramework2 how to get current page's URL in view templates

Originally posted and answered here:

https://groups.google.com/forum/#!topic/play-framework/s-ufMIbLz3c

But when I put:

<div>
 @if (request.uri == "/") { "Home Menu Selected" }
</div>

But I got:

'(' expected but ')' found.
like image 283
ses Avatar asked Sep 17 '13 01:09

ses


1 Answers

Assuming you have the request object in scope, sadly enough you just need to remove the space after "if". Play templates are pretty sensitive about spacing. Try:

<div>
 @if(request.uri == "/") { "Home Menu Selected" }
</div>
like image 129
Karl Avatar answered Nov 13 '22 16:11

Karl