Documentation
¶
Index ¶
- func BasicLiteralString(node ast.Node) (string, bool)
- func FindModificationReceiver(expr *ast.CallExpr, typesInfo *types.Info) types.Object
- func IsTemplateMethod(typesInfo *types.Info, sel *ast.SelectorExpr) bool
- func IsTemplatePkgIdent(info *types.Info, ident *ast.Ident) bool
- func RelativeFilePaths(wd string, abs ...string) ([]string, error)
- func StringLiteralExpression(wd string, set *token.FileSet, exp ast.Expr) (string, error)
- func StringLiteralExpressionList(wd string, set *token.FileSet, list []ast.Expr) ([]string, error)
- type Forrest
- type Template
- type TemplateFunctions
- type TemplateMetadata
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FindModificationReceiver ¶
FindModificationReceiver unwraps template.Must and returns the types.Object of the variable receiver for a method call like ts.ParseFS(...) or template.Must(ts.ParseFS(...)). Returns nil if no variable receiver is found.
func IsTemplateMethod ¶
func IsTemplateMethod(typesInfo *types.Info, sel *ast.SelectorExpr) bool
IsTemplateMethod reports whether sel refers to a method on *html/template.Template or *text/template.Template.
func IsTemplatePkgIdent ¶
IsTemplatePkgIdent reports whether ident refers to the "html/template" or "text/template" package via the type checker.
func StringLiteralExpression ¶
Types ¶
type Forrest ¶
func NewForrest ¶
type Template ¶
type Template interface {
New(name string) Template
Parse(text string) (Template, error)
Funcs(funcMap map[string]any) Template
Option(opt ...string) Template
Delims(left, right string) Template
Lookup(name string) Template
Name() string
AddParseTree(name string, tree *parse.Tree) (Template, error)
Tree() *parse.Tree
FindTree(name string) (*parse.Tree, bool)
}
Template abstracts over html/template.Template and text/template.Template so that the correct template package is used based on the user's import.
func EvaluateTemplateSelector ¶
func EvaluateTemplateSelector(ts Template, pkg *types.Package, typesInfo *types.Info, expression ast.Expr, workingDirectory, templatesVariable, rDelim, lDelim string, fileSet *token.FileSet, files []*ast.File, embeddedPaths []string, funcTypeMaps TemplateFunctions, fm map[string]any, meta *TemplateMetadata) (Template, string, string, error)
func NewTemplate ¶
NewTemplate creates a Template backed by the appropriate template package either: "text/template" or "html/template".
type TemplateFunctions ¶
func DefaultFunctions ¶
func DefaultFunctions(pkg *types.Package) TemplateFunctions
func (TemplateFunctions) FindFunction ¶
func (functions TemplateFunctions) FindFunction(name string) (*types.Signature, bool)
type TemplateMetadata ¶
TemplateMetadata accumulates metadata during template evaluation.