extends ../reference.jade

block documentation
  h1 Case

  p The case statement is a shorthand for JavaScript's <code>switch</code> statement and takes the following form:

  .row(data-control='interactive')
    .col-lg-6
      +jade
        :jadesrc
          - var friends = 10
          case friends
            when 0
              p you have no friends
            when 1
              p you have a friend
            default
              p you have \#{friends} friends
    .col-lg-6
      +html
        :htmlsrc
          <p>you have 10 friends</p>

  h2 Case Fall Through

  p You can use fall through just like in a select statement in JavaScript

  .row(data-control='interactive')
    .col-lg-6
      +jade
        :jadesrc
          - var friends = 0
          case friends
            when 0
            when 1
              p you have very few friends
            default
              p you have \#{friends} friends
    .col-lg-6
      +html
        :htmlsrc
          <p>you have very few friends</p>

  h2 Block Expansion

  p Block expansion may also be used:

  .row(data-control='interactive')
    .col-lg-6
      +jade
        :jadesrc
          - var friends = 1
          case friends
            when 0: p you have no friends
            when 1: p you have a friend
            default: p you have \#{friends} friends
    .col-lg-6
      +html
        :htmlsrc
          <p>you have a friend</p>
