Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7710163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:03:07+00:00 2026-06-01T01:03:07+00:00

I need to perform an equals comparison in my template, inorder to do a

  • 0

I need to perform an equals comparison in my template, inorder to do a conditional render.

For instance, I have <li class="active">. In here, I would like active only to be rendered if @request.path and @controllers.routes.Application.action() are equal, otherwise a blank string is fine.

the if statement as described in docs appears to be limited in recognizing the paranthesis and hence does not work.

Alternatively if you could help me with creating a custom tag, that could also work. There is no documentation on how to do that. I’ll prefer java. If there is a scala alternative, please err on the side of verbosity as I have yet to figure it out.

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:03:09+00:00Added an answer on June 1, 2026 at 1:03 am

    Without a custom tag, you can try something like this in your template :

    <li class="@("active".when(request.path == controllers.routes.Application.action().toString()))">
    

    There is an example in samples applications (samples/java/forms/app/views/main.scala.html).
    Dont forget the toString() because action() returns a Call, not a String).

    A custom tag to do that could be :

    @menu_element(name: String, route: Call) = {
     <li class="@("active".when(route.toString() == request.path))"><a href="@route">@name</a></li>
    }
    

    Example of use :

    <ul>
     @menu_element("Home", controllers.routes.Application.index)
    </ul>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to perform Diffs between Java strings. I would like to be able
I need to perform an action after a session times out. However I have
I need to perform queries in a ADO.NET model by using LINQ. I have
I need to perform a block of code like the following: x = some_number;
Why a generic method which constrains T to class would have boxing instructions in
I need to perform structural comparison on two Object[] arrays which may contain themselves:
I need to perform a few checks (enable or disable a label elsewhere on
I need to perform a find and replace using XSLT 1.0 which is really
I need to perform operations on Lua tables from C where the tables are
I need to perform some operations on all folders within a file share which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.