package templates
import "github.com/gohugoio/hugo/tpl/templates"
Package templates provides template functions for working with templates.
Index ¶
- type DeferOpts
- type Namespace
- func New(deps *deps.Deps) *Namespace
- func (ns *Namespace) Current(ctx context.Context) *tpl.CurrentTemplateInfo
- func (ns *Namespace) Defer(ctx context.Context, args ...any) (bool, error)
- func (ns *Namespace) DoDefer(ctx context.Context, id string, optsv any) string
- func (ns *Namespace) Exists(name string) bool
- func (ns *Namespace) Inner(ctx context.Context, data any) (any, error)
Types ¶
type DeferOpts ¶
type DeferOpts struct {
// Optional cache key. If set, the deferred block will be executed
// once per unique key.
Key string
// Optional data context to use when executing the deferred block.
Data any
}
type Namespace ¶
type Namespace struct {
// contains filtered or unexported fields
}
Namespace provides template functions for the "templates" namespace.
func New ¶
func New(deps *deps.Deps) *Namespace
New returns a new instance of the templates-namespaced template functions.
func (*Namespace) Current ¶
func (ns *Namespace) Current(ctx context.Context) *tpl.CurrentTemplateInfo
Get information about the currently executing template.
func (*Namespace) Defer ¶
Defer defers the execution of a template block.
func (*Namespace) DoDefer ¶
DoDefer defers the execution of a template block. For internal use only.
func (*Namespace) Exists ¶
Exists returns whether the template with the given name exists. Note that this is the Unix-styled relative path including filename suffix, e.g. partials/header.html
func (*Namespace) Inner ¶
Inner executes the inner content of a partial decorator. Note that there is only one inner block per partial decorator, but inner may be called multiple times with, typically, different data.
Source Files ¶
- Version
- v0.165.0 (latest)
- Published
- Aug 12, 2026
- Platform
- linux/amd64
- Imports
- 12 packages
- Last checked
- 3 hours ago –
Tools for package owners.