title: Go html template access struct fields inside range
body: <p>Given below struct, I want to access <code>field2</code> while iterating over <code>field1</code> data in html. How do I do this?</p>
  
  <pre><code>var MyPageData struct {
        field1 []Foo
        field2 map[string]Bar
  }
  </code></pre>
  
  <p>I tried: Inside Handler function:</p>
  
  <pre><code>err := myPageTemplate.Execute(w,MyPageData{ field1: field1Slice, field2 : myMapData})
  </code></pre>
  
  <p>Template:</p>
  
  <pre><code>     {{ range $index, $fooInstance := .field1}} 
          &lt;tr&gt;
              &lt;td&gt;{{$fooInstance.Name}}&lt;/td&gt; //This prints the Name value
              &lt;td&gt;{{ index .$field2 "myKey".Name }}&lt;/td&gt;
  </code></pre>
  
  <p>How do I access <code>field2</code> above and specify a key value to retrieve <code>Bar</code> instance?</p>
  
  <p><strong>UPDATE</strong> Adding Foo and Bar structs
  </p>
  
  <pre><code>type Foo2 struct {
      Name string
      Id  int 
  }
  
  
  type Foo struct {
      Name string
      element Foo2
  }
  
  type Bar struct {
      Name string
  }
  </code></pre>