hugo: github.com/gohugoio/hugo/tpl/internal Index | Files | Directories

package internal

import "github.com/gohugoio/hugo/tpl/internal"

Index

Package Files

templatefuncsRegistry.go

Variables

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

TemplateFuncsNamespaceRegistry describes a registry of functions that provide namespaces.

func AddTemplateFuncsNamespace Uses

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

AddTemplateFuncsNamespace adds a given function to a registry.

type TemplateFuncMethodMapping Uses

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 Uses

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 Uses

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

AddMethodMapping adds a method to a template function namespace.

type TemplateFuncsNamespaces Uses

type TemplateFuncsNamespaces []*TemplateFuncsNamespace

TemplateFuncsNamespaces is a slice of TemplateFuncsNamespace.

func (TemplateFuncsNamespaces) MarshalJSON Uses

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

MarshalJSON returns the JSON encoding of namespaces.

Directories

PathSynopsis
go_templates/fmtsortPackage fmtsort provides a general stable ordering mechanism for maps, on behalf of the fmt and text/template packages.
go_templates/htmltemplatePackage template (html/template) implements data-driven templates for generating HTML output safe against code injection.
go_templates/texttemplatePackage template implements data-driven templates for generating textual output.
go_templates/texttemplate/parsePackage parse builds parse trees for templates as defined by text/template and html/template.

Package internal imports 15 packages (graph) and is imported by 915 packages. Updated 2020-01-10. Refresh now. Tools for package owners.