Documentation
¶
Index ¶
- func FuncMap() ttemplate.FuncMap
- func FuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap
- func GenericFuncMap() map[string]any
- func GenericFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) map[string]any
- func HermeticHtmlFuncMap() htemplate.FuncMap
- func HermeticHtmlFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) htemplate.FuncMap
- func HermeticTxtFuncMap() ttemplate.FuncMap
- func HermeticTxtFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap
- func HtmlFuncMap() htemplate.FuncMap
- func HtmlFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) htemplate.FuncMap
- func TxtFuncMap() ttemplate.FuncMap
- func TxtFuncMapWith(opts ...sprout.HandlerOption[*SprigHandler]) ttemplate.FuncMap
- func WithLogger(l *slog.Logger) sprout.HandlerOption[*SprigHandler]
- type SprigHandler
- func (sh *SprigHandler) AddRegistries(registries ...sprout.Registry) error
- func (sh *SprigHandler) AddRegistry(registry sprout.Registry) error
- func (sh *SprigHandler) AmbiguousSignatureWarn(functionName, assumedSign, migratedSign string)
- func (sh *SprigHandler) BreakingWarn(functionName, changeNotice string)
- func (sh *SprigHandler) Build() sprout.FunctionMap
- func (sh *SprigHandler) Logger() *slog.Logger
- func (sh *SprigHandler) Notices() []sprout.FunctionNotice
- func (sh *SprigHandler) RawAliases() sprout.FunctionAliasMap
- func (sh *SprigHandler) RawFunctions() sprout.FunctionMap
- func (sh *SprigHandler) SignatureWarn(functionName, oldSign, newSign string)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func 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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
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.