tpl

package
v0.147.9 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2025 License: Apache-2.0 Imports: 11 Imported by: 230

Documentation

Overview

Package tpl contains template functions and related types.

Index

Constants

View Source
const (
	// HugoDeferredTemplatePrefix is the prefix for placeholders for deferred templates.
	HugoDeferredTemplatePrefix = "__hdeferred/"
	// HugoDeferredTemplateSuffix is the suffix for placeholders for deferred templates.
	HugoDeferredTemplateSuffix = "__d="
)

Variables

View Source
var Context = struct {
	DependencyManagerScopedProvider    hcontext.ContextDispatcher[identity.DependencyManagerScopedProvider]
	GetDependencyManagerInCurrentScope func(context.Context) identity.Manager
	DependencyScope                    hcontext.ContextDispatcher[int]
	Page                               hcontext.ContextDispatcher[page]
	IsInGoldmark                       hcontext.ContextDispatcher[bool]
	CurrentTemplate                    hcontext.ContextDispatcher[*CurrentTemplateInfo]
}{
	DependencyManagerScopedProvider: hcontext.NewContextDispatcher[identity.DependencyManagerScopedProvider](contextKeyDependencyManagerScopedProvider),
	DependencyScope:                 hcontext.NewContextDispatcher[int](contextKeyDependencyScope),
	Page:                            hcontext.NewContextDispatcher[page](contextKeyPage),
	IsInGoldmark:                    hcontext.NewContextDispatcher[bool](contextKeyIsInGoldmark),
	CurrentTemplate:                 hcontext.NewContextDispatcher[*CurrentTemplateInfo](cntextKeyCurrentTemplateInfo),
}

Context manages values passed in the context to templates.

Functions

func StripHTML added in v0.100.0

func StripHTML(s string) string

StripHTML strips out all HTML tags in s.

Types

type CurrentTemplateInfo added in v0.146.0

type CurrentTemplateInfo struct {
	Parent *CurrentTemplateInfo
	Level  int
	CurrentTemplateInfoOps
}

CurrentTemplateInfo as returned in templates.Current.

func (*CurrentTemplateInfo) Ancestors added in v0.146.0

func (ti *CurrentTemplateInfo) Ancestors() CurrentTemplateInfos

Ancestors returns the ancestors of the current template.

type CurrentTemplateInfoCommonOps added in v0.146.0

type CurrentTemplateInfoCommonOps interface {
	// Template name.
	Name() string
	// Template source filename.
	// Will be empty for internal templates.
	Filename() string
}

type CurrentTemplateInfoOps added in v0.146.0

type CurrentTemplateInfoOps interface {
	CurrentTemplateInfoCommonOps
	Base() CurrentTemplateInfoCommonOps
}

type CurrentTemplateInfos added in v0.146.0

type CurrentTemplateInfos []*CurrentTemplateInfo

CurrentTemplateInfos is a slice of CurrentTemplateInfo.

func (CurrentTemplateInfos) Reverse added in v0.146.0

Reverse creates a copy of the slice and reverses it.

type DeferredExecution added in v0.128.0

type DeferredExecution struct {
	Mu           sync.Mutex
	Ctx          context.Context
	TemplatePath string
	Data         any

	Executed bool
	Result   string
}

DeferredExecution holds the template and data for a deferred execution.

type RenderingContext added in v0.128.0

type RenderingContext struct {
	Site       site
	SiteOutIdx int
}

RenderingContext represents the currently rendered site/language.

type Template

type Template interface {
	Name() string
	Prepare() (*texttemplate.Template, error)
}

Template is the common interface between text/template and html/template.

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 diagrams provides template functions for generating diagrams.
Package diagrams provides template functions for generating diagrams.
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 hash provides non-cryptographic hash functions for template use.
Package hash provides non-cryptographic hash functions for template use.
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.
Package openapi provides functions for generating OpenAPI (Swagger) documentation.
Package openapi provides functions for generating OpenAPI (Swagger) documentation.
openapi3
Package openapi3 provides functions for generating OpenAPI v3 (Swagger) documentation.
Package openapi3 provides functions for generating OpenAPI v3 (Swagger) documentation.
Package os provides template functions for interacting with the operating system.
Package os provides template functions for interacting with the operating system.
Package page provides template functions for accessing the current Page object, the entry level context for the current template.
Package page provides template functions for accessing the current Page object, the entry level context for the current template.
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.

Jump to

Keyboard shortcuts

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