Back to godoc.org
github.com/gohugoio/hugo/tpl

package tpl

v0.71.1
Latest Go to latest
Published: 1 day ago | License: Apache-2.0 | Module: github.com/gohugoio/hugo

Index

Constants

const TemplateVersion = 2

Increments on breaking changes.

Variables

var DefaultParseConfig = ParseConfig{
	Version: TemplateVersion,
}
var DefaultParseInfo = ParseInfo{
	Config: DefaultParseConfig,
}

type Info

type Info interface {
	ParseInfo() ParseInfo

	// Identifies this template and its dependencies.
	identity.Provider
}

func NewInfo

func NewInfo(id identity.Manager, parseInfo ParseInfo) Info

type Info1

type Info1 struct {
}

Info holds some info extracted from a parsed template.

type InfoManager

type InfoManager interface {
	ParseInfo() ParseInfo

	// Identifies and manages this template and its dependencies.
	identity.Manager
}

type ParseConfig

type ParseConfig struct {
	Version int
}

type ParseInfo

type ParseInfo struct {
	// Set for shortcode templates with any {{ .Inner }}
	IsInner bool

	// Set for partials with a return statement.
	HasReturn bool

	// Config extracted from template.
	Config ParseConfig
}

func (ParseInfo) IsZero

func (info ParseInfo) IsZero() bool

type Template

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

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

func WithInfo

func WithInfo(templ Template, info Info) Template

WithInfo wraps the info in a template.

type TemplateDebugger

type TemplateDebugger interface {
	Debug()
}

TemplateDebugger prints some debug info to stdoud.

type TemplateFinder

type TemplateFinder interface {
	TemplateLookup
	TemplateLookupVariant
}

TemplateFinder finds templates.

type TemplateFuncGetter

type TemplateFuncGetter interface {
	GetFunc(name string) (reflect.Value, bool)
}

TemplateFuncGetter allows to find a template func by name.

type TemplateHandler

type TemplateHandler interface {
	TemplateFinder
	Execute(t Template, wr io.Writer, data interface{}) error
	LookupLayout(d output.LayoutDescriptor, f output.Format) (Template, bool, error)
	HasTemplate(name string) bool
}

TemplateHandler finds and executes templates.

type TemplateLookup

type TemplateLookup interface {
	Lookup(name string) (Template, bool)
}

type TemplateLookupVariant

type TemplateLookupVariant interface {
	// TODO(bep) this currently only works for shortcodes.
	// We may unify and expand this variant pattern to the
	// other templates, but we need this now for the shortcodes to
	// quickly determine if a shortcode has a template for a given
	// output format.
	// It returns the template, if it was found or not and if there are
	// alternative representations (output format, language).
	// We are currently only interested in output formats, so we should improve
	// this for speed.
	LookupVariant(name string, variants TemplateVariants) (Template, bool, bool)
}

type TemplateManager

type TemplateManager interface {
	TemplateHandler
	TemplateFuncGetter
	AddTemplate(name, tpl string) error
	MarkReady() error
}

TemplateManager manages the collection of templates.

type TemplateParseFinder

type TemplateParseFinder interface {
	TemplateParser
	TemplateFinder
}

TemplateParseFinder provides both parsing and finding.

type TemplateParser

type TemplateParser interface {
	Parse(name, tpl string) (Template, error)
}

TemplateParser is used to parse ad-hoc templates, e.g. in the Resource chain.

type TemplateVariants

type TemplateVariants struct {
	Language     string
	OutputFormat output.Format
}

TemplateVariants describes the possible variants of a template. All of these may be empty.

type TemplatesProvider

type TemplatesProvider interface {
	Tmpl() TemplateHandler
	TextTmpl() TemplateParseFinder
}

TemplatesProvider as implemented by deps.Deps.

Documentation was rendered with GOOS=linux and GOARCH=amd64.

Jump to identifier

Keyboard shortcuts

? : This menu
f or F : Jump to identifier