Reputation: 189
I am doing some conditional coding in scala template. just tell me how to write following java logic into scala.html template.
String temp = "";
if(!cityName.equals(temp)){
temp=cityName;
}
else{
//do something..
}
Upvotes: 0
Views: 227
Reputation: 55798
Scala views allows you to define some variables with @defining
block (see Reausable values), however it doesn't allow you to re-assignate
it, so your pseudocode won't work as expected.
In such case you need to write custom getter in your model, which will return a valid value, instead doing it with temporary values in the views. You can also access any static Java method which will process your incoming string according to some conditions.
I must to say, that I have no idea what exactly you want to achieve, however I think, that can be solved with solutions proposed above.
Upvotes: 1