By {{fullName author}}
{{body}}
Comments
{{#each comments}}By {{fullName author}}
{{content}}
{{/each}}
package handlebars_test import ( "fmt" "git.reinaldyrafli.com/aldy505/handlebars-go" ) func Example() { source := "
{{body.content}}
" ctx := map[string]interface{}{ "title": "foo", "body": map[string]string{"content": "bar"}, } // parse template tpl := handlebars.MustParse(source) // evaluate template with context output := tpl.MustExec(ctx) // alternatively, for one shots: // output := MustRender(source, ctx) fmt.Print(output) // Output:bar
} func Example_struct() { source := `{{body.content}}
" ctx := map[string]interface{}{ "title": "foo", "body": map[string]string{"content": "bar"}, } // render template with context output, err := handlebars.Render(tpl, ctx) if err != nil { panic(err) } fmt.Print(output) // Output:bar
} func ExampleMustRender() { tpl := "{{body.content}}
" ctx := map[string]interface{}{ "title": "foo", "body": map[string]string{"content": "bar"}, } // render template with context output := handlebars.MustRender(tpl, ctx) fmt.Print(output) // Output:bar
}