i want to render to my template 2 things at the same time like this:
String one = "one";
String two = "two";
return ok(template.render(one,two));
but Playframework says, it is wrong. how is it possible to render 2 values at the same time then? should i save them into a list? but then i have to unpack it again in my template.. :(
please help! appreciate any help!
Play templates in 2.0 are just Scala functions, so you need to declare params at the beginning of the template (beginning from line #1):
Check the templates docs for details
Map
On the other way if you need to pass large quantity of variables of the same type then the
Map
can be good solution as well:template.scala.html
View model
Finally to make things even more typesafe you can create your own
view models
like (sample):controller:
view: