internal

package
v0.63.3 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TemplateFuncsNamespaceRegistry []func(d *deps.Deps) *TemplateFuncsNamespace

TemplateFuncsNamespaceRegistry describes a registry of functions that provide namespaces.

Functions

func AddTemplateFuncsNamespace

func AddTemplateFuncsNamespace(ns func(d *deps.Deps) *TemplateFuncsNamespace)

AddTemplateFuncsNamespace adds a given function to a registry.

Types

type TemplateFuncMethodMapping

type TemplateFuncMethodMapping struct {
	Method interface{}

	// Any template funcs aliases. This is mainly motivated by keeping
	// backwards compatibility, but some new template funcs may also make
	// sense to give short and snappy aliases.
	// Note that these aliases are global and will be merged, so the last
	// key will win.
	Aliases []string

	// A slice of input/expected examples.
	// We keep it a the namespace level for now, but may find a way to keep track
	// of the single template func, for documentation purposes.
	// Some of these, hopefully just a few, may depend on some test data to run.
	Examples [][2]string
}

TemplateFuncMethodMapping represents a mapping of functions to methods for a given namespace.

type TemplateFuncsNamespace

type TemplateFuncsNamespace struct {
	// The namespace name, "strings", "lang", etc.
	Name string

	// This is the method receiver.
	Context func(v ...interface{}) interface{}

	// Additional info, aliases and examples, per method name.
	MethodMappings map[string]TemplateFuncMethodMapping
}

TemplateFuncsNamespace represents a template function namespace.

func (*TemplateFuncsNamespace) AddMethodMapping

func (t *TemplateFuncsNamespace) AddMethodMapping(m interface{}, aliases []string, examples [][2]string)

AddMethodMapping adds a method to a template function namespace.

type TemplateFuncsNamespaces

type TemplateFuncsNamespaces []*TemplateFuncsNamespace

TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace.

func (TemplateFuncsNamespaces) MarshalJSON

func (namespaces TemplateFuncsNamespaces) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of namespaces.

Directories

Path Synopsis
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.
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.
texttemplate
Package template implements data-driven templates for generating textual output.
Package template implements data-driven templates for generating textual output.
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.

Jump to

Keyboard shortcuts

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