package tpl
import "github.com/gohugoio/hugo/tpl"
Package tpl contains template functions and related types.
Index ¶
- Constants
- Variables
- func StripHTML(s string) string
- type CurrentTemplateInfo
- type CurrentTemplateInfoCommonOps
- type CurrentTemplateInfoOps
- type CurrentTemplateInfos
- type DeferredExecution
- type RenderingContext
- type Template
Constants ¶
const ( // HugoDeferredTemplatePrefix is the prefix for placeholders for deferred templates. HugoDeferredTemplatePrefix = "__hdeferred/" // HugoDeferredTemplateSuffix is the suffix for placeholders for deferred templates. HugoDeferredTemplateSuffix = "__d=" )
Variables ¶
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 ¶
StripHTML strips out all HTML tags in s.
Types ¶
type CurrentTemplateInfo ¶
type CurrentTemplateInfo struct { Parent *CurrentTemplateInfo CurrentTemplateInfoOps }
CurrentTemplateInfo as returned in templates.Current.
func (*CurrentTemplateInfo) Ancestors ¶
func (ti *CurrentTemplateInfo) Ancestors() CurrentTemplateInfos
Ancestors returns the ancestors of the current template.
type CurrentTemplateInfoCommonOps ¶
type CurrentTemplateInfoCommonOps interface { // Template name. Name() string // Template source filename. // Will be empty for internal templates. Filename() string }
type CurrentTemplateInfoOps ¶
type CurrentTemplateInfoOps interface { CurrentTemplateInfoCommonOps Base() CurrentTemplateInfoCommonOps }
type CurrentTemplateInfos ¶
type CurrentTemplateInfos []*CurrentTemplateInfo
CurrentTemplateInfos is a slice of CurrentTemplateInfo.
func (CurrentTemplateInfos) Reverse ¶
func (c CurrentTemplateInfos) Reverse() CurrentTemplateInfos
Reverse creates a copy of the slice and reverses it.
type DeferredExecution ¶
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 ¶
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.
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/css | |
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 | Package diagrams provides template functions for generating diagrams. |
tpl/encoding | Package encoding provides template functions for encoding content. |
tpl/fmt | Package fmt provides template functions for formatting strings. |
tpl/hash | Package hash provides non-cryptographic hash functions for template use. |
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 | Package openapi provides functions for generating OpenAPI (Swagger) documentation. |
tpl/openapi/openapi3 | Package openapi3 provides functions for generating OpenAPI v3 (Swagger) documentation. |
tpl/os | Package os provides template functions for interacting with the operating system. |
tpl/page | Package page provides template functions for accessing the current Page object, the entry level context for the current template. |
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/tplimplinit | |
tpl/transform | Package transform provides template functions for transforming content. |
tpl/urls | Package urls provides template functions to deal with URLs. |
- Version
- v0.146.2
- Published
- Apr 11, 2025
- Platform
- linux/amd64
- Imports
- 11 packages
- Last checked
- 1 second ago –
Tools for package owners.