title: Play Framework Templates - Iterating over a list issue
body: <p>I'm having an issue with iterating over a List that is passed to a Play Framework Template. I essentially have a query that fetches from a many-to-many association, and I want to render the parent key once and the associated keys several times.</p>
  
  <p>Below is the actual code I'm using:</p>
  
  <p>Using Slick, Scala and Play 2.0, I have the following table schema:</p>
  
  <pre><code>object Recipes extends Table[(Long, String, String)]("RECIPES") {
    def id = column[Long]("REC_ID", O.PrimaryKey, O.AutoInc)
    def cuisine = column[String]("CUISINE")
    def instructions = column[String]("INSTRUCTIONS")
    def * = id ~ cuisine ~ instructions
  }
  
  object Ingredients extends Table[(Long, String, String)]("INGREDIENTS") {
    def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
    def brand = column[String]("BRAND")
    def name = column[String]("NAME")
    def * = id ~ brand ~ name
  }
  
  object RecipeIngredient extends Table[(Long, Long, Long, Int, String)]("REC_ING") {
    def id = column[Long]("ID", O.PrimaryKey, O.AutoInc)
  
    def recID = column[Long]("REC_ID")
    def ingID = column[Long]("ING_ID")
    def quantity = column[Int]("QUANTITY")
    def units = column[String]("UNITS")
    def * = id ~ recID ~ ingID ~ quantity ~ units
    def recipe = foreignKey("REC_FK", recID, Recipes)(_.id)
    def ingredient = foreignKey("ING_FK", ingID, Ingredients)(_.id)
  }
  </code></pre>
  
  <p>I'm using Slick to generate the following query within a controller, and passing <code>q.list</code> to a view. The idea is to pass and render the recipe with ID 1 and all of it's associated ingredients:</p>
  
  <pre><code>val recID = 1.longValue() // Just a test to get the Recipe with ID === 1
  val q = for {
      r &lt;- Recipes if r.id === recID
      ri &lt;- RecipeIngredient if ri.recID === recID
  i &lt;-Ingredients if i.id === ri.ingID
  } yield (r.id, r.cuisine, r.instructions, ri.quantity, ri.units, i.brand, i.name)
  </code></pre>
  
  <p>My view is as follows:</p>
  
  <pre><code>@(message: String, result: List[(Long, String, String, Int, String, String, String)])
  
  @main("Site name") {
  
      @for((id, cuisine,instructions, quantity, units, brand, name) &lt;- result) {
  
      &lt;h2&gt;--Recipe--&lt;/h2&gt;
        RecID: @id &lt;br&gt;
        Cuisine: @cuisine &lt;br&gt;
        Instructions: @instructions &lt;br&gt;
  
        &lt;h2&gt;--Ingredients--&lt;/h2&gt;
        Ingredient: @quantity @units of @brand @name&lt;br&gt;
    }
  
  
  }
  </code></pre>
  
  <p>This is all well and good, but I get an output as follows:</p>
  
  <pre><code>--Recipe--
  RecID: 1 
  Cuisine: Chinese 
  Instructions: Instructions here..
  
  --Ingredients--
  Ingredient: 3 cloves of Generic Ginger
  
  --Recipe--
  RecID: 1 
  Cuisine: Chinese 
  Instructions: Instructions here..
  
  --Ingredients--
  Ingredient: 3 slices of Generic Cucumber
  </code></pre>
  
  <p>As you can see, the Recipe itself is repeated twice. What I ultimately want is the Recipe printed once, and the list of associated ingredients interated on and displayed after that (there may be multiple ingredients).</p>
  
  <p>Any ideas as to how to achieve this?</p>