entity

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 4, 2024 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ExecHelper

type ExecHelper struct {
	Funcs map[string]reflect.Value
}

func (*ExecHelper) GetFunc

func (t *ExecHelper) GetFunc(ctx context.Context, tmpl template.Preparer, name string) (fn reflect.Value, firstArg reflect.Value, found bool)

type ExecTemplate

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

func (*ExecTemplate) Name

func (et *ExecTemplate) Name() string

func (*ExecTemplate) Tree

func (et *ExecTemplate) Tree() *parser.Document

type Executor

type Executor struct {
	Helper template.ExecHelper
}

func (*Executor) ExecuteWithContext

func (t *Executor) ExecuteWithContext(ctx context.Context, p template.Preparer, wr io.Writer, data any) error

ExecuteWithContext Note: The context is currently not fully implemeted in Hugo. This is a work in progress.

type HtmlTemplate

type HtmlTemplate struct {
	// We could embed the text/template field, but it's safer not to because
	// we need to keep our version of the name space and the underlying
	// template's in sync.
	Text *TextTemplate

	*NameSpace // common to all associated templates
}

HtmlTemplate is a specialized ExecTemplate from "text/template" that produces a safe HTML document fragment.

func (*HtmlTemplate) Funcs

func (t *HtmlTemplate) Funcs(funcMap template.FuncMap) *HtmlTemplate

Funcs adds the elements of the argument map to the template's function map. It must be called before the template is parsed. It panics if a value in the map is not a function with appropriate return type. However, it is legal to overwrite elements of the map. The return value is the template, so calls can be chained.

func (*HtmlTemplate) Name

func (t *HtmlTemplate) Name() string

func (*HtmlTemplate) New

func (t *HtmlTemplate) New(name string) *HtmlTemplate

New allocates a new, undefined template associated with the given one and with the same delimiters. The association, which is transitive, allows one template to invoke another with a {{template}} action.

Because associated templates share underlying data, template construction cannot be done safely in parallel. Once the templates are constructed, they can be executed in parallel.

func (*HtmlTemplate) Parse

func (t *HtmlTemplate) Parse(text string) (*HtmlTemplate, error)

func (*HtmlTemplate) Prepare

func (t *HtmlTemplate) Prepare() (template.ExecTemplate, error)

Prepare returns a template ready for execution.

type NameSpace

type NameSpace struct {
	Set map[string]*HtmlTemplate
}

NameSpace is the data structure shared by all templates in an association.

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
}

type TemplateExec

type TemplateExec struct {
	Executor template.Executor
	Funcs    map[string]reflect.Value

	*TemplateHandler
}

func (*TemplateExec) ExecuteWithContext

func (t *TemplateExec) ExecuteWithContext(ctx context.Context, tmpl template.Template, wr io.Writer, data any) error

type TemplateHandler

type TemplateHandler struct {
	Main *TemplateNamespace
	Deps deps.Deps
}

func (*TemplateHandler) LoadTemplates

func (t *TemplateHandler) LoadTemplates() error

func (*TemplateHandler) Lookup

func (t *TemplateHandler) Lookup(name string) (template.Template, bool)

func (*TemplateHandler) LookupLayout

func (t *TemplateHandler) LookupLayout(layouts []string) (template.Template, bool, error)

type TemplateNamespace

type TemplateNamespace struct {
	PrototypeText *TextTemplate
	PrototypeHTML *HtmlTemplate

	*TemplateStateMap
}

func (*TemplateNamespace) Lookup

func (t *TemplateNamespace) Lookup(name string) (template.Template, bool)

type TemplateState

type TemplateState struct {
	template.Template
	// contains filtered or unexported fields
}

type TemplateStateMap

type TemplateStateMap struct {
	Templates map[string]*TemplateState
	// contains filtered or unexported fields
}

type TextTemplate

type TextTemplate struct {
	Name string
	Doc  *parser.Document
	// contains filtered or unexported fields
}

TextTemplate is the representation of a parsed template. The *parse.Tree field is exported only for use by html/template and should be treated as unexported by all other clients.

func (*TextTemplate) Funcs

func (t *TextTemplate) Funcs(funcMap template.FuncMap) *TextTemplate

Funcs adds the elements of the argument map to the template's function map. It must be called before the template is parsed. It panics if a value in the map is not a function with appropriate return type or if the name cannot be used syntactically as a function in a template. It is legal to overwrite elements of the map. The return value is the template, so calls can be chained.

func (*TextTemplate) New

func (t *TextTemplate) New(name string) *TextTemplate

New allocates a new, undefined template associated with the given one and with the same delimiters. The association, which is transitive, allows one template to invoke another with a {{template}} action.

Because associated templates share underlying data, template construction cannot be done safely in parallel. Once the templates are constructed, they can be executed in parallel.

func (*TextTemplate) Parse

func (t *TextTemplate) Parse(text string) (*TextTemplate, error)

Jump to

Keyboard shortcuts

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