Case

Case statements are the same as javascript switch statements. However unlike javascript switch statements they do not use a strict equality comparison due to the fact that html evaluates attributes as strings. So comparing '1' == 1 evaluates as true with mix case statements whereas in javascript it would evaluate to false using a switch.

Router.get('/', client.response.render('case.mix', {
  myVar: Math.floor(Math.random() * 15)
}))

case element

The case element starts the block of a case statement. It contains a evaluation attribute of :.

<case :="{{$myVar}}"></case>

when element

The when element is used to evaluate the value against the case statement. It looks nearly identical to the case element except that is it called when.

<when :="10">
  <span>Display when case statement is 10</span>
</when>

default element

The default element has no attributes, and it will display if none of the the when elements evaluate to true.

<default>
  <span>Nothing matched the case statement</span>
</default>

Full example


  <case :="{{$myVar}}">
    <when :="1">
      <p>$myVar is equal to 1!</p>
    </when>
    <when :="2">
      <p>$myVar is equal to 2!</p>
    </when>
    <default>
      <p>$myVar does not contain a valid value.</p>
    </default>
  </case>