Play! Framework (2.6.2) passing route with type Call to custom view

173 Views Asked by At

I have a question about passing a play.api.mvc Call parameter from one .scala.html file to another. The basic idea of the view I want to create is a reusable confirmation dialog that shows up on different actions, and different screens. So being able to pass a Call parameter that gets executed when the user clicks Yes.

Here is the code I am using in my customConfirm.scala.html view:

@(call: Call)

<div>
    <div> Are you sure ? </div>
    <a href="@call"> Yes </a>
    <div> No </div>
</div>

And this is the code where I am calling it:

@views.html.partials._customConfirm(@routes.HomeController.welcome())

This last peace of code gives me a compilation error:

illegal start of simple expression

Am I missing something, or is this method a completely wrong way of going about it? Any help would be greatly appreciated!

1

There are 1 best solutions below

0
rethab On BEST ANSWER

Omit the @ when calling the reverse router:

@views.html.partials._customConfirm(routes.HomeController.welcome())