Documentation
¶
Index ¶
- Constants
- Variables
- func GetDataFromContext(ctx context.Context) any
- func GetHasLockFromContext(ctx context.Context) bool
- func SetHasLockInContext(ctx context.Context, hasLock bool) context.Context
- func StripHTML(s string) string
- type FileInfo
- type Info
- type InfoManager
- type ParseConfig
- type ParseInfo
- type Template
- type TemplateDebugger
- type TemplateFinder
- type TemplateFuncGetter
- type TemplateHandler
- type TemplateLookup
- type TemplateLookupVariant
- type TemplateManager
- type TemplateParseFinder
- type TemplateParser
- type TemplateVariants
- type TemplatesProvider
- type UnusedTemplatesProvider
Constants ¶
const TemplateVersion = 2
Increments on breaking changes.
Variables ¶
var DefaultParseConfig = ParseConfig{ Version: TemplateVersion, }
var DefaultParseInfo = ParseInfo{ Config: DefaultParseConfig, }
Functions ¶
func GetDataFromContext ¶ added in v1.0.0
GetDataFromContext returns the template data context (usually .Page) from ctx if set. NOte: This is not fully implemented yet.
func GetHasLockFromContext ¶ added in v1.0.0
func SetHasLockInContext ¶ added in v1.0.0
Types ¶
type Info ¶ added in v1.0.0
type InfoManager ¶ added in v1.0.0
type ParseConfig ¶ added in v1.0.0
type ParseConfig struct {
Version int
}
type ParseInfo ¶ added in v1.0.0
type ParseInfo struct {
// Set for shortcode templates with any {{ .Inner }}
IsInner bool
// Set for partials with a return statement.
HasReturn bool
// Config extracted from template.
Config ParseConfig
}
type Template ¶
type Template interface {
Name() string
Prepare() (*texttemplate.Template, error)
}
Template is the common interface between text/template and html/template.
type TemplateDebugger ¶ added in v0.22.1
type TemplateDebugger interface {
Debug()
}
TemplateDebugger prints some debug info to stdout.
type TemplateFinder ¶ added in v0.20.1
type TemplateFinder interface {
TemplateLookup
TemplateLookupVariant
}
TemplateFinder finds templates.
type TemplateFuncGetter ¶ added in v1.0.0
TemplateFuncGetter allows to find a template func by name.
type TemplateHandler ¶ added in v0.20.1
type TemplateHandler interface {
TemplateFinder
Execute(t Template, wr io.Writer, data any) error
ExecuteWithContext(ctx context.Context, t Template, wr io.Writer, data any) error
LookupLayout(d output.LayoutDescriptor, f output.Format) (Template, bool, error)
HasTemplate(name string) bool
}
TemplateHandler finds and executes templates.
type TemplateLookup ¶ added in v1.0.0
type TemplateLookupVariant ¶ added in v1.0.0
type TemplateLookupVariant interface {
// TODO(bep) this currently only works for shortcodes.
// We may unify and expand this variant pattern to the
// other templates, but we need this now for the shortcodes to
// quickly determine if a shortcode has a template for a given
// output format.
// It returns the template, if it was found or not and if there are
// alternative representations (output format, language).
// We are currently only interested in output formats, so we should improve
// this for speed.
LookupVariant(name string, variants TemplateVariants) (Template, bool, bool)
LookupVariants(name string) []Template
}
type TemplateManager ¶ added in v1.0.0
type TemplateManager interface {
TemplateHandler
TemplateFuncGetter
AddTemplate(name, tpl string) error
MarkReady() error
}
TemplateManager manages the collection of templates.
type TemplateParseFinder ¶ added in v0.45.1
type TemplateParseFinder interface {
TemplateParser
TemplateFinder
}
TemplateParseFinder provides both parsing and finding.
type TemplateParser ¶ added in v0.45.1
TemplateParser is used to parse ad-hoc templates, e.g. in the Resource chain.
type TemplateVariants ¶ added in v1.0.0
TemplateVariants describes the possible variants of a template. All of these may be empty.
type TemplatesProvider ¶ added in v1.0.0
type TemplatesProvider interface {
Tmpl() TemplateHandler
TextTmpl() TemplateParseFinder
}
TemplatesProvider as implemented by deps.Deps.
type UnusedTemplatesProvider ¶ added in v1.0.0
type UnusedTemplatesProvider interface {
UnusedTemplates() []FileInfo
}
UnusedTemplatesProvider lists unused templates if the build is configured to track those.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package cast provides template functions for data type conversions.
|
Package cast provides template functions for data type conversions. |
|
Package collections provides template functions for manipulating collections such as arrays, maps, and slices.
|
Package collections provides template functions for manipulating collections such as arrays, maps, and slices. |
|
Package compare provides template functions for comparing values.
|
Package compare provides template functions for comparing values. |
|
Package crypto provides template functions for cryptographic operations.
|
Package crypto provides template functions for cryptographic operations. |
|
Package data provides template functions for working with external data sources.
|
Package data provides template functions for working with external data sources. |
|
Package debug provides template functions to help debugging templates.
|
Package debug provides template functions to help debugging templates. |
|
Package encoding provides template functions for encoding content.
|
Package encoding provides template functions for encoding content. |
|
Package fmt provides template functions for formatting strings.
|
Package fmt provides template functions for formatting strings. |
|
Package hugo provides template functions for accessing the Site Hugo object.
|
Package hugo provides template functions for accessing the Site Hugo object. |
|
Package images provides template functions for manipulating images.
|
Package images provides template functions for manipulating images. |
|
Package inflect provides template functions for the inflection of words.
|
Package inflect provides template functions for the inflection of words. |
|
go_templates/cfg
Package cfg holds configuration shared by the Go command and internal/testenv.
|
Package cfg holds configuration shared by the Go command and internal/testenv. |
|
go_templates/fmtsort
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
|
Package fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages. |
|
go_templates/htmltemplate
Package template (html/template) implements data-driven templates for generating HTML output safe against code injection.
|
Package template (html/template) implements data-driven templates for generating HTML output safe against code injection. |
|
go_templates/testenv
Package testenv provides information about what functionality is available in different testing environments run by the Go team.
|
Package testenv provides information about what functionality is available in different testing environments run by the Go team. |
|
go_templates/texttemplate
Package template implements data-driven templates for generating textual output.
|
Package template implements data-driven templates for generating textual output. |
|
go_templates/texttemplate/parse
Package parse builds parse trees for templates as defined by text/template and html/template.
|
Package parse builds parse trees for templates as defined by text/template and html/template. |
|
Package js provides functions for building JavaScript resources
|
Package js provides functions for building JavaScript resources |
|
Package lang provides template functions for content internationalization.
|
Package lang provides template functions for content internationalization. |
|
Package math provides template functions for mathematical operations.
|
Package math provides template functions for mathematical operations. |
|
openapi
|
|
|
Package os provides template functions for interacting with the operating system.
|
Package os provides template functions for interacting with the operating system. |
|
Package partials provides template functions for working with reusable templates.
|
Package partials provides template functions for working with reusable templates. |
|
Package path provides template functions for manipulating paths.
|
Package path provides template functions for manipulating paths. |
|
Package reflect provides template functions for run-time object reflection.
|
Package reflect provides template functions for run-time object reflection. |
|
Package resources provides template functions for working with resources.
|
Package resources provides template functions for working with resources. |
|
Package safe provides template functions for escaping untrusted content or encapsulating trusted content.
|
Package safe provides template functions for escaping untrusted content or encapsulating trusted content. |
|
Package site provides template functions for accessing the Site object.
|
Package site provides template functions for accessing the Site object. |
|
Package strings provides template functions for manipulating strings.
|
Package strings provides template functions for manipulating strings. |
|
Package templates provides template functions for working with templates.
|
Package templates provides template functions for working with templates. |
|
Package time provides template functions for measuring and displaying time.
|
Package time provides template functions for measuring and displaying time. |
|
Package transform provides template functions for transforming content.
|
Package transform provides template functions for transforming content. |
|
Package urls provides template functions to deal with URLs.
|
Package urls provides template functions to deal with URLs. |