How do you declare and initialize a variable to be used locally in a Play2 Scala template?
I have this:
@var title : String = \"Home\"
In twirl templates I would recommend using the defining block, because the
@random = @{
new Random().nextInt
}
<div id="@random"></div>
<div id="@random"></div>
would result in different values when used multiple times!
@defining(new Random().nextInt){ random =>
<div id="@random"></div>
<div id="@random"></div>
}
@defining("foo") { title=>
<div>@title</div>
...
}
basically, you have to wrap the block in which you are going to use it