Actually, the @ c4k solution works (and quite conveniently) until you try to change the value of the variable after that, right?
You simply place this at the top of the template:
@yourVariable = {yourValue}
or, if this is a more complex expression, you do this:
@yourVariable = @{yourExpression}
You can even work with things like lists:
@(listFromController: List[MyObject]) @filteredList = @{listFromController.filter(_.color == "red")} @for(myObject <- filteredList){ ... }
In this example, it will be
@title = {Home} //this should be at beginning of the template, right after passing in parameters <h1> Using title @title </h1>
In the comments you said, it is injected into the HTML type. However, this is only relevant if you try to overwrite @title again, right?
ollie Aug 04 '15 at 9:11 2015-08-04 09:11
source share