sprigin

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 27 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FuncMap

func FuncMap() ttemplate.FuncMap

FuncMap returns a template.FuncMap for use with text/template or html/template. It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARD COMPATIBILITY ONLY

func FuncMapWith added in v1.1.0

func FuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap

FuncMapWith behaves like FuncMap and applies the given handler options, such as WithLogger. An option returning an error is reported through the handler logger and skipped, the function map is still built. FOR BACKWARD COMPATIBILITY ONLY

func GenericFuncMap

func GenericFuncMap() map[string]any

GenericFuncMap returns a copy of the basic function map as a map[string]any. It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARDS COMPATIBILITY ONLY

func GenericFuncMapWith added in v1.1.0

func GenericFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) map[string]any

GenericFuncMapWith behaves like GenericFuncMap and applies the given handler options, such as WithLogger. FOR BACKWARDS COMPATIBILITY ONLY

func HermeticHtmlFuncMap

func HermeticHtmlFuncMap() htemplate.FuncMap

HermeticHtmlFuncMap returns an 'html/template'.Funcmap with only repeatable functions. It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARDS COMPATIBILITY ONLY

func HermeticHtmlFuncMapWith added in v1.1.0

func HermeticHtmlFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) htemplate.FuncMap

HermeticHtmlFuncMapWith behaves like HermeticHtmlFuncMap and applies the given handler options, such as WithLogger. FOR BACKWARDS COMPATIBILITY ONLY

func HermeticTxtFuncMap

func HermeticTxtFuncMap() ttemplate.FuncMap

HermeticTxtFuncMap returns a 'text/template'.FuncMap with only repeatable functions. It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARDS COMPATIBILITY ONLY

func HermeticTxtFuncMapWith added in v1.1.0

func HermeticTxtFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap

HermeticTxtFuncMapWith behaves like HermeticTxtFuncMap and applies the given handler options, such as WithLogger. FOR BACKWARDS COMPATIBILITY ONLY

func HtmlFuncMap

func HtmlFuncMap() htemplate.FuncMap

HtmlFuncMap returns an 'html/template'.Funcmap It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARDS COMPATIBILITY ONLY

func HtmlFuncMapWith added in v1.1.0

func HtmlFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) htemplate.FuncMap

HtmlFuncMapWith behaves like HtmlFuncMap and applies the given handler options, such as WithLogger. FOR BACKWARDS COMPATIBILITY ONLY

func TxtFuncMap

func TxtFuncMap() ttemplate.FuncMap

TxtFuncMap returns a 'text/template'.FuncMap It provides backward compatibility with sprig.FuncMap and integrates additional configured functions. FOR BACKWARDS COMPATIBILITY ONLY

func TxtFuncMapWith added in v1.1.0

func TxtFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap

TxtFuncMapWith behaves like TxtFuncMap and applies the given handler options, such as WithLogger. FOR BACKWARDS COMPATIBILITY ONLY

func WithLogger added in v1.1.0

func WithLogger(l *slog.Logger) sprout.HandlerOption[*SprigHandler]

WithLogger allows sprigin user to provide their logger system using slog

Types

type SprigHandler

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

func NewSprigHandler

func NewSprigHandler() *SprigHandler

func (*SprigHandler) AddRegistries

func (sh *SprigHandler) AddRegistries(registries ...sprout.Registry) error

func (*SprigHandler) AddRegistry

func (sh *SprigHandler) AddRegistry(registry sprout.Registry) error

func (*SprigHandler) AmbiguousSignatureWarn added in v1.1.0

func (sh *SprigHandler) AmbiguousSignatureWarn(functionName, assumedSign, migratedSign string)

AmbiguousSignatureWarn logs a warning message when the arguments of a call match both the Sprig and the Sprout signatures, which happens when the receiver and the value have the same type, e.g. appending a list to a list.

The call cannot be disambiguated from the arguments alone, so the Sprig signature is assumed for backward compatibility. Callers already migrated to the Sprout signature get their arguments swapped, hence a message of its own instead of the migration one, which would tell them to move to the very signature they already use.

func (*SprigHandler) BreakingWarn added in v1.1.0

func (sh *SprigHandler) BreakingWarn(functionName, changeNotice string)

func (*SprigHandler) Build

func (sh *SprigHandler) Build() sprout.FunctionMap

func (*SprigHandler) Logger

func (sh *SprigHandler) Logger() *slog.Logger

func (*SprigHandler) Notices added in v0.6.0

func (sh *SprigHandler) Notices() []sprout.FunctionNotice

func (*SprigHandler) RawAliases added in v0.6.0

func (sh *SprigHandler) RawAliases() sprout.FunctionAliasMap

func (*SprigHandler) RawFunctions added in v0.6.0

func (sh *SprigHandler) RawFunctions() sprout.FunctionMap

func (*SprigHandler) SignatureWarn added in v1.1.0

func (sh *SprigHandler) SignatureWarn(functionName, oldSign, newSign string)

SignatureWarn logs a warning message about a deprecated function signature. This is used to warn users when they use the old Sprig signature instead of the new Sprout signature.

oldSign and newSign are shown side by side, so they must differ only by what the user has to change. For the functions returning a new value that is usually accumulated, both should carry the assignment, otherwise the message reads as if the call alone was enough.

Jump to

Keyboard shortcuts

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