Documentation ¶
Index ¶
- Variables
- type Template
- func (t *Template) AddParseTree(name string, tree *parse.Tree) (*Template, error)
- func (t *Template) ExecuteTemplateToFile(name string, file string, overwrite bool, data any) error
- func (t *Template) ExecuteToFile(file string, overwrite bool, data any) error
- func (t *Template) Funcs(funcMap template.FuncMap) *Template
- func (t *Template) Parse(text string) (*Template, error)
- func (t *Template) ParseFS(fs embed.FS, patterns ...string) (*Template, error)
- func (t *Template) ParseFiles(filenames ...string) (*Template, error)
- func (t *Template) ParseGlob(pattern string) (*Template, error)
- func (t *Template) ParseReader(r io.Reader) (*Template, error)
Constants ¶
This section is empty.
Variables ¶
var DefaultTemplateFuncMap = template.FuncMap{ "toCamel": str.ToCamel, "toLowerCamel": str.ToLowerCamel, "toSnake": str.ToSnake, "toKebab": str.ToKebab, "toScreamingKebab": str.ToScreamingKebab, "toDelimited": str.ToDelimited, "toScreamingDelimited": str.ToScreamingDelimited, "toSnakeWithIgnore": str.ToSnakeWithIgnore, "lower": strings.ToLower, "upper": strings.ToUpper, "replace": strings.ReplaceAll, "hasPrefix": strings.HasPrefix, "hasSuffix": strings.HasSuffix, "split": strings.Split, "toString": str.ToString, "join": strings.Join, "quote": strconv.Quote, "ucFirst": str.UcFirst, "lcFirst": str.LcFirst, "trim": strings.Trim, "trimLeft": strings.TrimLeft, "trimRight": strings.TrimRight, "trimSpace": strings.TrimSpace, "trimPrefix": strings.TrimPrefix, "trimSuffix": strings.TrimSuffix, "contains": strings.Contains, }
Functions ¶
This section is empty.
Types ¶
type Template ¶
func (*Template) AddParseTree ¶
AddParseTree adds the argument parsetree to the template definition
func (*Template) ExecuteTemplateToFile ¶
ExecuteTemplateToFile executes a template with the given name and writes the output to a file. if Overwrite is true, the file will be overwritten if it exists.
func (*Template) ExecuteToFile ¶
ExecuteToFile executes the template to file, if overwrite is true, the file will be overwritten if it exists.
func (*Template) Funcs ¶
Funcs adds the elements of the argument map to the template's functionx map.
func (*Template) ParseFS ¶
ParseFS parses the files in the embedded filesystem. returns an error if any of the files fail to parse.
func (*Template) ParseFiles ¶
ParseFiles creates a new Template and parses the template definitions from the named files. if any file contains an error, the first such error is returned and the rest are ignored.