tpl

package
v0.0.0-...-5b3a7c8 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const TemplateVersion = 2

Increments on breaking changes.

Variables

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

Functions

func StripHTML

func StripHTML(s string) string

StripHTML strips out all HTML tags in s.

Types

type FileInfo

type FileInfo interface {
	Name() string
	Filename() string
}

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 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.

type TemplateFinder

type TemplateFinder interface {
	TemplateLookup
}

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 any) error
	ExecuteWithContext(ctx context.Context, t Template, wr io.Writer, data any) 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 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.

Directories

Path Synopsis
Package compare provides template functions for comparing values.
Package compare provides template functions for comparing values.
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 os provides template functions for interacting with the operating system.
Package os provides template functions for interacting with the operating system.
Package transform provides template functions for transforming content.
Package transform provides template functions for transforming content.

Jump to

Keyboard shortcuts

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