I have this scala template and want to use a case statement to render different html based on a matching enum value.
My template looks like this:
@(tagStatus: String)
try {
TagStatus.withName(tagStatus) match {
case TagStatus.deployed => {<span class="label label-success">@tagStatus</span>}
case TagStatus.deployedPartially => {<span class="label label-important">@tagStatus</span>}
case TagStatus.deployedWithProblems => {<span class="label label-important">@tagStatus</span>}
}
} catch {
{<span class="label label-important">??</span>}
}
The enum looks something like this:
object TagStatus extends Enumeration{
val deployed = Value("deployed")
val deployedWithProblems = Value("deployed_with_problems")
val deployedPartially = Value("deployed_partially")
}
When i run this i get:
Compilation error
')' expected but 'case' found.
In C:\...\statusTag.scala.html at line 8.
5 case TagStatus.deployed => {<span class="label label-success">@tagStatus</span>}
6 case TagStatus.deployedPartially => {<span class="label label-important">@tagStatus</span>}
7 case TagStatus.deployedWithProblems => {<span class="label label-important">@tagStatus</span>}
8 }
9 } catch {
10 {<span class="label label-important">??</span>}
11 }
I have not idea what is meant by this error message.
What am i missing in order to get this simple code snippet to compile?
Thanks!