Documentation
¶
Index ¶
- Variables
- type Aborted
- type Executor
- type ExecutorFunc
- type Factory
- func (t *Factory) AddFuncs(in ...FuncMap) *Factory
- func (t *Factory) AddMatcher(in ...Matcher) *Factory
- func (t *Factory) AddMatcherFunc(in ...MatcherFunc) *Factory
- func (t *Factory) Default(in Parser) *Factory
- func (t *Factory) DefaultFunc(in ParserFunc) *Factory
- func (t *Factory) FileReader(in FileReader) *Factory
- func (t *Factory) FileReaderFunc(in FileReaderFunc) *Factory
- func (t Factory) From(s string) Template
- func (t Factory) FromFile(templateFile string) Template
- func (t Factory) FromName(name, s string) Template
- type FileReader
- type FileReaderFunc
- type FormatEngine
- type FuncMap
- type Map
- type Matcher
- type MatcherFunc
- type Parser
- type ParserFunc
- type Template
Constants ¶
This section is empty.
Variables ¶
var ParserFormat = ParserFunc(FormatParser)
var ParserHTML = ParserFunc(HTMLParser)
var ParserText = ParserFunc(TextParser)
Functions ¶
This section is empty.
Types ¶
type Aborted ¶
type Aborted interface {
Aborted() error
}
Aborted is a special purpose error used to signal an aborted template execution. It prevents saving output files.
type ExecutorFunc ¶
ExecutorFunc executes a template against an io.Writer given the context.
type Factory ¶ added in v0.3.0
type Factory struct {
// contains filtered or unexported fields
}
Factory allows fluent execution of templates and runtime selection of the template engine.
func New ¶
New creates a properly initialized Factory. Name is an arbitrary label passed to the internal template engines
func (*Factory) AddMatcher ¶ added in v0.3.0
func (*Factory) AddMatcherFunc ¶ added in v0.3.0
func (t *Factory) AddMatcherFunc(in ...MatcherFunc) *Factory
func (*Factory) DefaultFunc ¶ added in v0.3.0
func (t *Factory) DefaultFunc(in ParserFunc) *Factory
func (*Factory) FileReader ¶ added in v0.3.0
func (t *Factory) FileReader(in FileReader) *Factory
FileReader allows overriding how filenames are evaluated and loaded.
func (*Factory) FileReaderFunc ¶ added in v0.3.0
func (t *Factory) FileReaderFunc(in FileReaderFunc) *Factory
FileReaderFunc allows overriding how filenames are evaluated and loaded.
type FileReader ¶
FileReader allows overriding how filenames are evaluated and loaded.
type FileReaderFunc ¶
FileReaderFunc allows overriding how filenames are evaluated and loaded.
type FormatEngine ¶ added in v0.2.0
type FormatEngine struct {
// contains filtered or unexported fields
}
FormatEngine uses the golang fmt package to process a string. Warning: It is not possible to generate an error for an invalid format string. Go will embed the error message in the output string, for example: `%!d(string=foo)` for an invalid type or `%!s(MISSING)` for missing data
type FuncMap ¶
type FuncMap map[string]interface{}
FuncMap maps template function names to functions.
type Map ¶ added in v0.3.0
Map is a thread-safe cache for templates
func (*Map) Delete ¶ added in v0.3.0
Delete an item from the Map. Does nothing if the key is not in the Map.
type MatcherFunc ¶
MatcherFunc is used to match a file name to a Parser.
func (MatcherFunc) Match ¶
func (f MatcherFunc) Match(filename string) Parser
type Parser ¶
Parser reads the input template string and returns an executable Template.
func MatchFormat ¶ added in v0.2.0
MatchFormat returns a Go Format Parser if the filename ends with ".format" or ".string" or ".goformat"
type ParserFunc ¶
ParserFunc reads the input template string and returns an executable Template.
type Template ¶
type Template interface {
To(data interface{}) (string, error)
ToFile(file string, data interface{}) error
ToWriter(w io.Writer, data interface{}) error
}
Template is used to execute the parsed template and write the output to a string, File, or io.Writer.