Documentation
¶
Index ¶
- Variables
- func Render(data string, context ...interface{}) (string, error)
- func RenderFile(filename string, context ...interface{}) (string, error)
- func RenderFileInLayout(filename string, layoutFile string, context ...interface{}) (string, error)
- func RenderInLayout(data string, layoutData string, context ...interface{}) (string, error)
- type Tag
- type TagType
- type Template
Constants ¶
This section is empty.
Variables ¶
var ( // AllowMissingVariables defines the behavior for a variable "miss." If it // is true (the default), an empty string is emitted. If it is false, an error // is generated instead. AllowMissingVariables = true )
Functions ¶
func Render ¶
Render compiles a mustache template string and uses the the given data source - generally a map or struct - to render the template and return the output.
func RenderFile ¶
RenderFile loads a mustache template string from a file and compiles it, and then uses the the given data source - generally a map or struct - to render the template and return the output.
func RenderFileInLayout ¶
RenderFileInLayout loads a mustache template string and layout "wrapper" template string from files and compiles them, and then uses the the given data source - generally a map or struct - to render the compiled templates and return the output.
func RenderInLayout ¶
RenderInLayout compiles a mustache template string and layout "wrapper" and uses the given data source - generally a map or struct - to render the compiled templates and return the output.
Types ¶
type Tag ¶
type Tag interface {
// Type returns the type of the tag.
Type() TagType
// Name returns the name of the tag.
Name() string
// Tags returns any child tags. It panics for tag types which cannot contain
// child tags (i.e. variable tags).
Tags() []Tag
}
Tag represents the different mustache tag types.
Not all methods apply to all kinds of tags. Restrictions, if any, are noted in the documentation for each method. Use the Type method to find out the type of tag before calling type-specific methods. Calling a method inappropriate to the type of tag causes a run time panic.
type TagType ¶
type TagType uint
A TagType represents the specific type of mustache tag that a Tag represents. The zero TagType is not a valid type.
Defines representing the possible Tag types
type Template ¶
type Template struct {
// contains filtered or unexported fields
}
Template represents a compilde mustache template
func ParseFile ¶
ParseFile loads a mustache template string from a file and compiles it. The resulting output can be used to efficiently render the template multiple times with different data sources.
func ParseString ¶
ParseString compiles a mustache template string. The resulting output can be used to efficiently render the template multiple times with different data sources.
func (*Template) Render ¶
Render uses the given data source - generally a map or struct - to render the compiled template and return the output.
func (*Template) RenderInLayout ¶
RenderInLayout uses the given data source - generally a map or struct - to render the compiled template and layout "wrapper" template and return the output.