I am new to Scala (Scala templates in Play 2 framework), I want to do the following: Pass a parameter isEdit and depending on this parameter, define a value, Pseudocode:
variable myTitle;
if(isEdit)
myTitle="edit question";
else
myTitle="create question";
How to formulate this in a Scala Template in Play 2.0? Passing isEdit is not the problem, only creating the new variable myTitle. Thanks :-)
Not so sure what you are asking, you can do this:
Or this:
First of all, look over the Playframework documentation as there's a lot of good info on templates there. http://www.playframework.org/documentation/2.0.4/ScalaTemplates
Now, if you need to reuse the value throughout the template then you can declare it at the top of your template (probably after any @imports):
If you only need it in one spot then you really just need the if-else block:
you can try this, working for me in similar case
You cannot use variables in that way in a view template (correct me if im wrong). I would use javascript do to what you want to do, ie pass isEdit to some javascript function and from that set the title.