Reputation: 6669
I have an app that is a backend and does not have views. Now I have to add the "terms of service" and I my idea is to serve a partial HTML. I do not want to have all the HTML because then I will embed this in different places (WEB and Mobile).
this is my view
@{
<h1>Hello world!!!</h1>
}
My controller
object TosEndpoints extends Controller {
def get() = PublicApi.async {
Ok(views.html.tos("Terms of service"))
}
}
my routes.conf
GET /tos controllers.TosEndpoints.get()
I can not serve the content of the view
I get for example this error
app/views/tos.html.scala:1: identifier expected but '{' found.
[error] @{
UPDATE
If I remove the arguments I get the same error.
If I pass one argument and bind it in the view (as suggested @AliDehghani) I get this error app/views/tos.html.scala:1: ')' expected but ':' found. [error] @(tos: String)
Upvotes: 0
Views: 81
Reputation: 48123
The problem is that you're calling the view with too many arguments. You should either fix the render part by removing the extra argument:
Ok(views.html.tos())
Or change your view in a way that it accepts the passed argument, something like following:
@(tos: String)
<h1>Hello world!!!</h1>
<p>@tos</p>
Then you can render the view by:
Ok(views.html.tos("Terms of service"))
Upvotes: 1