templates

package
v0.0.0-...-8705ae5 Latest Latest
Warning

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

Go to latest
Published: Jun 20, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const FuncNameFromYaml = "fromYaml"

FuncNameFromYaml is the name of the template function which converts yaml strings to objects.

View Source
const FuncNameInclude = "include"

FuncNameInclude is the name of the "include" template function.

View Source
const FuncNameIndex = "index"

FuncNameIndex is the name of the "index" template function.

View Source
const FuncNameToYaml = "toYaml"

FuncNameToYaml is the name of the template function which converts objects to yaml strings.

Variables

This section is empty.

Functions

func AddPackageSpecificTemplateFunctions

func AddPackageSpecificTemplateFunctions(tmpl *template.Template) *template.Template

AddPackageSpecificTemplateFunctions adds the package-specific template functions for the given template.

func ChainTemplatesFromDir

func ChainTemplatesFromDir(parentTemplate *template.Template, templatesDirPath string) (*template.Template, int, error)

ChainTemplatesFromDir returns a single template which contains all of the templates that were found in the given directory.

func ExecuteNamedTemplate

func ExecuteNamedTemplate(tmpl *template.Template, templateName string, values interface{}) ([]byte, error)

ExecuteNamedTemplate executes a named template that can be found in the provided template.

func ExecuteTemplate

func ExecuteTemplate(tmpl *template.Template, values interface{}) ([]byte, error)

ExecuteTemplate executes a template given the template object and the values.

func FromYamlFunc

func FromYamlFunc(yamlString string) (*types.GenericMap, error)

FromYamlFunc converts yaml strings to objects.

func GetGlobalFuncMap

func GetGlobalFuncMap() map[string]interface{}

GetGlobalFuncMap returns the template functions which can be used in any context.

func GetIncludeFunc

func GetIncludeFunc(tmpl *template.Template) interface{}

GetIncludeFunc creates a new instance of the Include function, which allows helper templates to be executed so their output can be used in other functions.

func GetPackageFuncMap

func GetPackageFuncMap(tmpl *template.Template) map[string]interface{}

GetPackageFuncMap returns the template functions which can be used only in the context of a particular template. If the template provided is nil, placeholder template functions are provided which return "Not implemented" errors.

func GetTemplateFromFile

func GetTemplateFromFile(parentTemplate *template.Template, templateName string, filePath string) (*template.Template, error)

GetTemplateFromFile returns a new template object given a template file.

func GetTemplatesFromDir

func GetTemplatesFromDir(parentTemplate *template.Template, templatesDirPath string) ([]*template.Template, error)

GetTemplatesFromDir returns an array containing all of the templates found in the given directory.

func IndexFunc

func IndexFunc(data interface{}, keys ...string) (interface{}, error)

IndexFunc gets a single value from a generic map (of any depth), given an ordered list of keys.

func NewRootTemplate

func NewRootTemplate() *template.Template

NewRootTemplate returns a new root template with options and functions provided.

func ToYamlFunc

func ToYamlFunc(value interface{}) (string, error)

ToYamlFunc converts objects to yaml strings.

Types

This section is empty.

Jump to

Keyboard shortcuts

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