Note that there are some explanatory texts on larger screens.

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

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload