Index
- Variables
- func Import[T any](extension T) func() T
- type AsyncExtension
- type B64Extension
- type ConvExtension
- func (e *ConvExtension) Bool(val any) bool
- func (e *ConvExtension) Float(val any) float64
- func (e *ConvExtension) Float64(val any) float64
- func (e *ConvExtension) FuncMap() template.FuncMap
- func (e *ConvExtension) Int(val any) int
- func (e *ConvExtension) Ptr(val any) any
- func (e *ConvExtension) String(val any) string
- type EnvExtension
- type ErrorsxExtension
- type FmtxExtension
- func (e *FmtxExtension) FuncMap() template.FuncMap
- func (e *FmtxExtension) Number(number float64, precision int, prefix, suffix string) string
- func (e *FmtxExtension) NumberP0(number float64) string
- func (e *FmtxExtension) NumberP1(number float64) string
- func (e *FmtxExtension) Numeral(number float64, precision int) string
- func (e *FmtxExtension) NumeralP0(number float64) string
- func (e *FmtxExtension) NumeralP1(number float64) string
- type JsonxExtension
- type MapxExtension
- type MathxExtension
- type RegexpxExtension
- type SliceExtension
- type StringsExtension
- func (e *StringsExtension) Contains(str string, substr string) bool
- func (e *StringsExtension) FuncMap() template.FuncMap
- func (e *StringsExtension) Lower(str string) string
- func (e *StringsExtension) Replace(str, old, new string) string
- func (e *StringsExtension) Sprintf(format string, a ...any) string
- func (e *StringsExtension) Title(str string) string
- func (e *StringsExtension) Trim(str string) string
- func (e *StringsExtension) Upper(str string) string
- type TimeExtension
Variables
FuncMap is a map of utilities functions to be used in templates.
var FuncMap = template.FuncMap{
"mathx": Import(&MathxExtension{}),
"async": Import(&AsyncExtension{}),
"b64": Import(&B64Extension{}),
"conv": Import(&ConvExtension{}),
"errorsx": Import(&ErrorsxExtension{}),
"fmtx": Import(&FmtxExtension{}),
"jsonx": Import(&JsonxExtension{}),
"mapx": Import(&MapxExtension{}),
"regexpx": Import(&RegexpxExtension{}),
"slice": Import(&SliceExtension{}),
"time": Import(&TimeExtension{}),
"env": Import(&EnvExtension{}),
"strings": Import(&StringsExtension{}),
}
func Import
func Import[T any](extension T) func() T
Import allows to pack a given struct into getter function. In that way, you're able to use struct and struct methods as funcmap extensions.
Usage:
// Example of import
example := template.FuncMap{ "jsonx": Import(&templatex.JsonxExtension{}) }
// Example of usage
"{{ jsonx.String .Value }}"
type AsyncExtension
AsyncExtension is a template compatibility wrapper around existing async zen package.
type AsyncExtension struct{}
func (*AsyncExtension) Await
func (e *AsyncExtension) Await(f async.ImplementsAwaitRuntime) (any, error)
func (*AsyncExtension) FuncMap
func (e *AsyncExtension) FuncMap() template.FuncMap
type B64Extension
B64Extension is a template compatibility wrapper around existing b64 zen package.
type B64Extension struct{}
func (*B64Extension) Base64
func (e *B64Extension) Base64(value string) string
func (*B64Extension) Base64Bytes
func (e *B64Extension) Base64Bytes(value []byte) string
func (*B64Extension) FuncMap
func (e *B64Extension) FuncMap() template.FuncMap
func (*B64Extension) String
func (e *B64Extension) String(b64string string) string
type ConvExtension
ConvExtension is a template compatibility wrapper around existing conv zen package.
type ConvExtension struct{}
func (*ConvExtension) Bool
func (e *ConvExtension) Bool(val any) bool
func (*ConvExtension) Float
func (e *ConvExtension) Float(val any) float64
func (*ConvExtension) Float64
func (e *ConvExtension) Float64(val any) float64
func (*ConvExtension) FuncMap
func (e *ConvExtension) FuncMap() template.FuncMap
func (*ConvExtension) Int
func (e *ConvExtension) Int(val any) int
func (*ConvExtension) Ptr
func (e *ConvExtension) Ptr(val any) any
func (*ConvExtension) String
func (e *ConvExtension) String(val any) string
type EnvExtension
EnvExtension is a template compatibility wrapper around existing environment-related package.
type EnvExtension struct{}
func (*EnvExtension) FuncMap
func (e *EnvExtension) FuncMap() template.FuncMap
func (*EnvExtension) Get
func (e *EnvExtension) Get(key string) string
type ErrorsxExtension
ErrorsxExtension is a template compatibility wrapper around existing errorsx zen package.
type ErrorsxExtension struct{}
func (*ErrorsxExtension) FuncMap
func (e *ErrorsxExtension) FuncMap() template.FuncMap
func (*ErrorsxExtension) Ignore
func (e *ErrorsxExtension) Ignore(val any, err error) any
func (*ErrorsxExtension) Must
func (e *ErrorsxExtension) Must(val any, err error) any
type FmtxExtension
AsyncExtension is a template compatibility wrapper around existing async zen package.
type FmtxExtension struct{}
func (*FmtxExtension) FuncMap
func (e *FmtxExtension) FuncMap() template.FuncMap
func (*FmtxExtension) Number
func (e *FmtxExtension) Number(number float64, precision int, prefix, suffix string) string
func (*FmtxExtension) NumberP0
func (e *FmtxExtension) NumberP0(number float64) string
func (*FmtxExtension) NumberP1
func (e *FmtxExtension) NumberP1(number float64) string
func (*FmtxExtension) Numeral
func (e *FmtxExtension) Numeral(number float64, precision int) string
func (*FmtxExtension) NumeralP0
func (e *FmtxExtension) NumeralP0(number float64) string
func (*FmtxExtension) NumeralP1
func (e *FmtxExtension) NumeralP1(number float64) string
type JsonxExtension
JsonxExtension is a template compatibility wrapper around existing jsonx zen package.
type JsonxExtension struct{}
func (*JsonxExtension) FuncMap
func (e *JsonxExtension) FuncMap() template.FuncMap
func (*JsonxExtension) String
func (e *JsonxExtension) String(value any) string
type MapxExtension
MapxExtension is a template compatibility wrapper around existing mapx zen package.
type MapxExtension struct{}
func (*MapxExtension) Compose
func (e *MapxExtension) Compose(vals ...any) map[any]any
func (*MapxExtension) FuncMap
func (e *MapxExtension) FuncMap() template.FuncMap
type MathxExtension
MathxExtension is a template compatibility wrapper around existing mathx zen package.
type MathxExtension struct{}
func (*MathxExtension) DivRuntime
func (e *MathxExtension) DivRuntime(vals ...any) any
func (*MathxExtension) FuncMap
func (e *MathxExtension) FuncMap() template.FuncMap
func (*MathxExtension) MulRuntime
func (e *MathxExtension) MulRuntime(vals ...any) any
func (*MathxExtension) SubRuntime
func (e *MathxExtension) SubRuntime(vals ...any) any
func (*MathxExtension) SumRuntime
func (e *MathxExtension) SumRuntime(vals ...any) any
type RegexpxExtension
RegexpxExtension is a template compatibility wrapper around existing regexpx zen package.
type RegexpxExtension struct{}
func (*RegexpxExtension) FuncMap
func (e *RegexpxExtension) FuncMap() template.FuncMap
func (*RegexpxExtension) Replace
func (e *RegexpxExtension) Replace(str, old, new string) string
type SliceExtension
SliceExtension is a template compatibility wrapper around existing slice zen package.
type SliceExtension struct{}
func (*SliceExtension) FuncMap
func (e *SliceExtension) FuncMap() template.FuncMap
func (*SliceExtension) In
func (e *SliceExtension) In(val any, sliceval any) bool
func (*SliceExtension) Range
func (e *SliceExtension) Range(from, to int) []int
type StringsExtension
StringsExtension is a template compatibility wrapper around existing string-related packages.
type StringsExtension struct{}
func (*StringsExtension) Contains
func (e *StringsExtension) Contains(str string, substr string) bool
func (*StringsExtension) FuncMap
func (e *StringsExtension) FuncMap() template.FuncMap
func (*StringsExtension) Lower
func (e *StringsExtension) Lower(str string) string
func (*StringsExtension) Replace
func (e *StringsExtension) Replace(str, old, new string) string
func (*StringsExtension) Sprintf
func (e *StringsExtension) Sprintf(format string, a ...any) string
func (*StringsExtension) Title
func (e *StringsExtension) Title(str string) string
func (*StringsExtension) Trim
func (e *StringsExtension) Trim(str string) string
func (*StringsExtension) Upper
func (e *StringsExtension) Upper(str string) string
type TimeExtension
TimeExtension is a template compatibility wrapper around existing time package.
type TimeExtension struct{}
func (*TimeExtension) FuncMap
func (e *TimeExtension) FuncMap() template.FuncMap
func (*TimeExtension) Now
func (e *TimeExtension) Now() time.Time
func (*TimeExtension) Nowfmt
func (e *TimeExtension) Nowfmt(format string) string
Generated by gomarkdoc