Documentation
¶
Index ¶
- func AddPathAliases(tmpl *template.Template, names []string) error
- func DefinedTemplates(name, src string) ([]string, error)
- func FilterFuncMap(funcs template.FuncMap, required map[string]struct{}) template.FuncMap
- func FunctionNameSignature(funcs template.FuncMap) string
- func FunctionNameSignatureFromNames(names []string) string
- func FunctionNameSignatureFromSet(names map[string]struct{}) string
- func MergeFuncMaps(funcMaps ...template.FuncMap) template.FuncMap
- func MergeFunctionSignatures(signatures ...string) string
- func Names(funcs template.FuncMap) map[string]struct{}
- func NormalizeContractType(typeName string) string
- func PathAliases(name string) []string
- func PathBase(name string) string
- func ReferencedTemplates(name, src string) ([]string, error)
- func RequiredFuncs(name, src string) ([]string, error)
- type CachedTemplate
- type ContractDeclaration
- type FileScan
- type RootContract
- type Scanner
- func (s Scanner) DefinedTemplates(names []string) map[string]struct{}
- func (s Scanner) File(name string) (*FileScan, error)
- func (s Scanner) IsFile(name string) bool
- func (s Scanner) ReferencedTemplates(names []string) map[string]struct{}
- func (s Scanner) RequiredFuncs(names []string) (map[string]struct{}, error)
- func (s Scanner) RootContracts(names []string) (map[string]RootContract, error)
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefinedTemplates ¶
func FilterFuncMap ¶
func FunctionNameSignature ¶
func MergeFunctionSignatures ¶
func NormalizeContractType ¶
func PathAliases ¶
func ReferencedTemplates ¶
func RequiredFuncs ¶
Types ¶
type CachedTemplate ¶
type CachedTemplate struct {
// contains filtered or unexported fields
}
func NewCachedTemplate ¶
func NewCachedTemplate(base *template.Template, requiredFuncs map[string]struct{}) *CachedTemplate
func (*CachedTemplate) TemplateResolving ¶ added in v0.14.0
func (cached *CachedTemplate) TemplateResolving(resolve func(name string) (any, bool)) (*template.Template, func(), error)
TemplateResolving is Template with the functions the template calls looked up by resolve, rather than filtered from a map of every function.
type ContractDeclaration ¶ added in v0.14.0
ContractDeclaration is one typed root declaration, such as "@model Site github.com/acme/site.Site".
type FileScan ¶ added in v0.14.0
type FileScan struct {
Defined []string
Referenced []string
Required []string
Contracts []ContractDeclaration
// ParseErr is set when the file does not parse; Defined, Referenced and
// Required are empty then.
ParseErr error
}
FileScan is what one template file declares and uses: the templates it defines and calls, the functions it calls, and its typed root declarations.
func ScanTemplate ¶ added in v0.14.0
ScanTemplate reads what the template source declares and uses, parsing it once.
type RootContract ¶
type Scanner ¶ added in v0.14.0
type Scanner struct {
// contains filtered or unexported fields
}
Scanner reads template files from one file system. With a key, which identifies the file system, each file is scanned once and kept in the store, for template trees whose files do not change.
func (Scanner) DefinedTemplates ¶ added in v0.14.0
DefinedTemplates returns the names the files can be called by: their paths, base names and aliases, and the templates they define.
func (Scanner) IsFile ¶ added in v0.14.0
IsFile reports whether name is a file. With a key, files found are remembered.
func (Scanner) ReferencedTemplates ¶ added in v0.14.0
ReferencedTemplates returns the templates the files call. Files that cannot be read or parsed are skipped; parsing them for rendering reports why.
func (Scanner) RequiredFuncs ¶ added in v0.14.0
RequiredFuncs returns the functions the files call.
func (Scanner) RootContracts ¶ added in v0.14.0
func (s Scanner) RootContracts(names []string) (map[string]RootContract, error)
RootContracts returns the typed root declarations of the files by root name. A name declared with two types is an error.