Skip to content
Go to file
Cannot retrieve contributors at this time
48 lines (41 sloc) 766 Bytes
package templates
import (
type HelloData struct {
Name string
Email string
Lang string
Entries []*Entry
type Entry struct {
Type string
Title string
{{func Hello(d *HelloData)}}
<h1>{{fmt.Sprintf("Hi, %s", d.Name)}} {{d.MyEmail()}}</h1>
{{ for _, e := range d.Entries }}
<li>{{EntryItem(e, d.Lang)}}</li>
{{ end }}
{{func EntryItem(e *Entry, lang string)}}
{{switch e.Type }}
{{case "post"}}
<div class="post">{{e.Title}}</div>
{{case "comment"}}
<div class="comment">{{e.Title}}</div>
<div class="entry">{{e.Title}}</div>
{{if lang == "english"}}
Written in English
Unknown Language
{{func (h *HelloData) MyEmail()}}
<em>My Email is: {{h.Email}}</em>