Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Template)
func WithStrictMode ¶
func WithStrictMode() Option
WithStrictMode sets the strict mode option for the template, using the standard Go unmarshaller for JSON
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
func (*Template) Execute ¶
Execute uses the parsed template to execute the provided value and populate the result variable.
Example ¶
template, _ := New(`{"template": "Hello, {{.name}}!"}`) data := map[string]any{"name": "World"} result := make(map[string]any) if err := template.Execute(&result, data); err != nil { fmt.Println("Error: ", err) } fmt.Println(result["template"])
Output: Hello, World!
Click to show internal directories.
Click to hide internal directories.