If you need to traverse the alphabet in Scala automatically, you can create a loop that proceses the single letters.

The following code was used in a Play Template (view) to traverse the alphabet and show the differnt links depending on the existence of a single letter in the cityLetters sequence. If the letter is in the sequence, the link is active, otherwise inactive.

@(cityLetters: Seq[String] = Seq.empty)

@defining('A' to 'Z'){ alphabet =>
  @for(l <- alphabet) {
    @defining(l.toString) { letter =>
      @if(cityLetters.contains(letter)) {
        <a class="btn btn-default" href="@routes.CityController.listing(letter)">@letter</a>
      } else {
        <a class="btn btn-default" disabled="disabled" href="#">@letter</a>

Leave a Reply