package partials

import "github.com/gohugoio/hugo/tpl/partials"

Package partials provides template functions for working with reusable templates.

Index

Types

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) Include

func (ns *Namespace) Include(ctx context.Context, name string, contextList ...any) (any, error)

Include executes the named partial. If the partial contains a return statement, that value will be returned. Else, the rendered output will be returned: A string if the partial is a text/template, or template.HTML when html/template. Note that ctx is provided by Hugo, not the end user.

func (*Namespace) IncludeCached

func (ns *Namespace) IncludeCached(ctx context.Context, name string, context any, variants ...any) (any, error)

IncludeCached executes and caches partial templates. The cache is created with name+variants as the key. Note that ctx is provided by Hugo, not the end user.

Source Files

init.go partials.go

Version
v0.144.2 (latest)
Published
Feb 19, 2025
Platform
linux/amd64
Imports
14 packages
Last checked
7 hours ago

Tools for package owners.