More functional approach I wonder if there is a more "functional" way of implementing something like this:

@months.zipWithIndex.foreach { case (month, index) =&gt;
    if (index%3 == 0) {
        &lt;tr&gt;
    }
    &lt;td&gt;@month&lt;/td&gt;
    if (index%3 == 0) {
        &lt;/tr&gt;
    }
}


Can these two if-statements be removed by using something other than foreach?
I am not sure which framework you are using, but this is how you could do it using Scala´s native XML library:

 &lt;div&gt;
 { for (row &lt;- months grouped 3) yield (&lt;tr&gt; { for (month &lt;- row) yield (&lt;td&gt; {month} &lt;/td&gt;) } &lt;/tr&gt;) }
 &lt;/div&gt;


Rendered slightly more prettily, the code looks like this:

for (row &lt;- months grouped 3) yield {
  &lt;tr&gt; 
  { for (month &lt;- row) yield (&lt;td&gt; {month} &lt;/td&gt;) }
  &lt;/tr&gt;
}


Which hopefully makes the structure clear.

If your framework works with yield, all you need to do is add @ in the appropriate places.  If it does not, you might have to do something like this:

for (row &lt;- @months grouped 3) {
  &lt;tr&gt;
  for (month &lt;- @row) {
    &lt;td&gt; @month &lt;/td&gt;
  }
  &lt;/tr&gt;
}


Your code is structured only around months, so has to use conditional logic to create your rows.  My code is structured around rows (and within that around months), so needs no conditionals.  My code also only has the value for the number of months in one place, which is less error prone and makes it easier to change the number of months in a row.

You don't have to use a list comprehension, though.  The important thing is simply to slice the list up into groups of 3 (or n, where n is the number of months you want in each row) and iterate over those.