title: Go: Print each element in slice on new line with html/template
body: <p>How do I print "apple", "orange", and "pear" on a new line?</p>
  
  <p>GO:</p>
  
  <pre><code>const titlepage = `
  &lt;html&gt;
  &lt;h1&gt;{{ .Title}}&lt;/h1&gt;
  &lt;h1&gt;{{ range $i := .Body}}{{$i}}{{end}}&lt;/h1&gt;
  &lt;/html&gt;
  `
  type tp struct {
      Title string
      Body []string
  }
  
  func Read() ([]string) {
      a := []string{"apple", "orange", "pear"}
      return a
  }
  
  func main() {
      as := tp{Title: "Hello", Body: Read()}
      t := template.Must(template.New("Tele").Parse(titlepage))
      t.Execute(os.Stdout, as)
  }
  </code></pre>
  
  <p>Current output:</p>
  
  <pre><code>&lt;html&gt;
  &lt;h1&gt;Hello&lt;/h1&gt;
  &lt;h1&gt;appleorangepear&lt;/h1&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>The code on Go Playground: <a href="http://play.golang.org/p/yhyfcq--MM" rel="nofollow">http://play.golang.org/p/yhyfcq--MM</a></p>