title: play 2.0 templates html select with if statement in a map
body: <p>I want to create a <code>&lt;select&gt;</code> without using the helpers (because the select helper is generating a <em>lot</em> of html)</p>
  
  <p>So, I get a list of cities from the Controller like:</p>
  
  <pre><code>public static List&lt;City&gt; getAllSortedByNameAsc() {
      List&lt;City&gt; cities = new ArrayList&lt;City&gt;();
      cities.addAll(City.find.orderBy("name").findList());
      return cities;
  }
  </code></pre>
  
  <p>In my template, I create the options with this code:</p>
  
  <pre><code>@cities.map { city =&gt;
      &lt;option value="@city.id"&gt;@city.name&lt;/option&gt;
  }
  </code></pre>
  
  <p>which works, but I also want to have the chosen city as selected value. I tried several things like this:</p>
  
  <pre><code>@cities.map { city =&gt;
      &lt;option value="@city.id" selected="@if(offerForm("city.id").value == city.id){selected}"&gt;@city.name&lt;/option&gt;
  }
  </code></pre>
  
  <p>But that doesn't work. Can anyone give me a hint?</p>