partials

package
v0.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 9, 2024 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package partials provides template functions for working with reusable templates.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Namespace

type Namespace struct {
	// contains filtered or unexported fields
}

Namespace provides template functions for the "templates" namespace.

func New

func New(cb func(ctx context.Context, name string, data any) (tmpl string, res any, err error)) *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.

type TemplateExecutor

type TemplateExecutor func(ctx context.Context, name string, data any) (tmpl string, res any, err error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL