Documentation
¶
Overview ¶
Package mustachio provides a fast, spec-compliant Mustache template engine for Go.
Mustachio implements the Mustache templating language specification (https://mustache.github.io/mustache.5.html) with support for:
- Variables with HTML escaping: {{name}}
- Unescaped variables: {{{name}}} and {{& name}}
- Sections and inverted sections: {{#section}}...{{/section}}
- Partials: {{> user}}
- Set delimiters: {{=<% %>=}}
- Lambda functions (optional spec feature)
- Numeric indexing in dotted names
Example:
template := "Hello {{name}}!"
data := map[string]any{"name": "World"}
result, err := mustachio.Render(template, data, nil)
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type MapPartials ¶
func (MapPartials) LoadPartial ¶
func (m MapPartials) LoadPartial(name string) (string, bool)
type MapProvider ¶
type MapProvider struct {
// contains filtered or unexported fields
}
func NewMapProvider ¶
func NewMapProvider(root any) *MapProvider
func (*MapProvider) Push ¶
func (p *MapProvider) Push(ctx any) ValueProvider
type PartialLoader ¶
type ValueProvider ¶
type ValueProvider interface {
// Lookup returns a value for a given dotted name within the current stack of contexts.
// If not found, returns (nil, false).
Lookup(name string) (any, bool)
// Push returns a new provider with an additional context pushed on top of the stack.
Push(ctx any) ValueProvider
}
Click to show internal directories.
Click to hide internal directories.