package tpl
import "github.com/gohugoio/hugo/tpl"
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 ¶
GetDataFromContext returns the template data context (usually .Page) from ctx if set. NOte: This is not fully implemented yet.
func GetHasLockFromContext ¶
func SetHasLockInContext ¶
func StripHTML ¶
StripHTML strips out all HTML tags in s.
Types ¶
type FileInfo ¶
type Info ¶
type Info interface { ParseInfo() ParseInfo // Identifies this template and its dependencies. identity.Provider }
func NewInfo ¶
type InfoManager ¶
type InfoManager interface { ParseInfo() ParseInfo // Identifies and manages this template and its dependencies. identity.Manager }
type ParseConfig ¶
type ParseConfig struct { Version int }
type ParseInfo ¶
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 }
func (ParseInfo) IsZero ¶
type Template ¶
type Template interface { Name() string Prepare() (*texttemplate.Template, error) }
Template is the common interface between text/template and html/template.
func WithInfo ¶
WithInfo wraps the info in a template.
type TemplateDebugger ¶
type TemplateDebugger interface {
Debug()
}
TemplateDebugger prints some debug info to stdout.
type TemplateFinder ¶
type TemplateFinder interface { TemplateLookup TemplateLookupVariant }
TemplateFinder finds templates.
type TemplateFuncGetter ¶
TemplateFuncGetter allows to find a template func by name.
type TemplateHandler ¶
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 ¶
type TemplateLookupVariant ¶
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 ¶
type TemplateManager interface { TemplateHandler TemplateFuncGetter AddTemplate(name, tpl string) error MarkReady() error }
TemplateManager manages the collection of templates.
type TemplateParseFinder ¶
type TemplateParseFinder interface { TemplateParser TemplateFinder }
TemplateParseFinder provides both parsing and finding.
type TemplateParser ¶
TemplateParser is used to parse ad-hoc templates, e.g. in the Resource chain.
type TemplateVariants ¶
TemplateVariants describes the possible variants of a template. All of these may be empty.
type TemplatesProvider ¶
type TemplatesProvider interface { Tmpl() TemplateHandler TextTmpl() TemplateParseFinder }
TemplatesProvider as implemented by deps.Deps.
type UnusedTemplatesProvider ¶
type UnusedTemplatesProvider interface { UnusedTemplates() []FileInfo }
UnusedTemplatesProvider lists unused templates if the build is configured to track those.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
tpl/cast | Package cast provides template functions for data type conversions. |
tpl/collections | Package collections provides template functions for manipulating collections such as arrays, maps, and slices. |
tpl/compare | Package compare provides template functions for comparing values. |
tpl/crypto | Package crypto provides template functions for cryptographic operations. |
tpl/data | Package data provides template functions for working with external data sources. |
tpl/debug | Package debug provides template functions to help debugging templates. |
tpl/diagrams | |
tpl/encoding | Package encoding provides template functions for encoding content. |
tpl/fmt | Package fmt provides template functions for formatting strings. |
tpl/hugo | Package hugo provides template functions for accessing the Site Hugo object. |
tpl/images | Package images provides template functions for manipulating images. |
tpl/inflect | Package inflect provides template functions for the inflection of words. |
tpl/internal | |
tpl/js | Package js provides functions for building JavaScript resources |
tpl/lang | Package lang provides template functions for content internationalization. |
tpl/math | Package math provides template functions for mathematical operations. |
tpl/openapi | |
tpl/openapi/openapi3 | |
tpl/os | Package os provides template functions for interacting with the operating system. |
tpl/partials | Package partials provides template functions for working with reusable templates. |
tpl/path | Package path provides template functions for manipulating paths. |
tpl/reflect | Package reflect provides template functions for run-time object reflection. |
tpl/resources | Package resources provides template functions for working with resources. |
tpl/safe | Package safe provides template functions for escaping untrusted content or encapsulating trusted content. |
tpl/site | Package site provides template functions for accessing the Site object. |
tpl/strings | Package strings provides template functions for manipulating strings. |
tpl/templates | Package templates provides template functions for working with templates. |
tpl/time | Package time provides template functions for measuring and displaying time. |
tpl/tplimpl | |
tpl/transform | Package transform provides template functions for transforming content. |
tpl/urls | Package urls provides template functions to deal with URLs. |
- Version
- v0.101.0
- Published
- Jun 16, 2022
- Platform
- darwin/amd64
- Imports
- 11 packages
- Last checked
- 26 minutes ago –
Tools for package owners.