title: Grails nested g:each
body: <p>I am trying to loop through a list of fields in my index view. Lets say I pass the following to index.gsp:</p>
  
  <pre><code>[SomeDomainList: SomeDomain.list(), fields: ['field1', 'field2', 'field3']]
  </code></pre>
  
  <p>And then in index.gsp I have:</p>
  
  <pre><code>&lt;g:each in="SomeDomainList" var="SomeDomainInstance"&gt;
      &lt;g:each in="fields" var="field"&gt;
          &lt;td&gt;${SomeDomainInstance.field}&lt;/td&gt;
      &lt;/g:each&gt;
  &lt;/g:each&gt;
  </code></pre>
  
  <p>I would think that since the SomeDomainInstance variable gets evaluated that the field variable would get evaluated also. However, I get a "No such property: field for class: SomeDomain". I also tried:</p>
  
  <pre><code>&lt;td&gt;${SomeDomainInstance.${field}}&lt;/td&gt;
  </code></pre>
  
  <p>But that results in a "Unclosed GSP expression" error. Can anyone tell me how I can achieve this?</p>