internal

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: 5 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 any

	// 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 ...any) (any, error)

	// 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 any, 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.

Directories

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

Jump to

Keyboard shortcuts

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