Skip to content
On this page

Index

Variables

FuncMap is a map of utilities functions to be used in templates.

go
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

go
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.

go
type AsyncExtension struct{}

func (*AsyncExtension) Await

go
func (e *AsyncExtension) Await(f async.ImplementsAwaitRuntime) (any, error)

func (*AsyncExtension) FuncMap

go
func (e *AsyncExtension) FuncMap() template.FuncMap

type B64Extension

B64Extension is a template compatibility wrapper around existing b64 zen package.

go
type B64Extension struct{}

func (*B64Extension) Base64

go
func (e *B64Extension) Base64(value string) string

func (*B64Extension) Base64Bytes

go
func (e *B64Extension) Base64Bytes(value []byte) string

func (*B64Extension) FuncMap

go
func (e *B64Extension) FuncMap() template.FuncMap

func (*B64Extension) String

go
func (e *B64Extension) String(b64string string) string

type ConvExtension

ConvExtension is a template compatibility wrapper around existing conv zen package.

go
type ConvExtension struct{}

func (*ConvExtension) Bool

go
func (e *ConvExtension) Bool(val any) bool

func (*ConvExtension) Float

go
func (e *ConvExtension) Float(val any) float64

func (*ConvExtension) Float64

go
func (e *ConvExtension) Float64(val any) float64

func (*ConvExtension) FuncMap

go
func (e *ConvExtension) FuncMap() template.FuncMap

func (*ConvExtension) Int

go
func (e *ConvExtension) Int(val any) int

func (*ConvExtension) Ptr

go
func (e *ConvExtension) Ptr(val any) any

func (*ConvExtension) String

go
func (e *ConvExtension) String(val any) string

type EnvExtension

EnvExtension is a template compatibility wrapper around existing environment-related package.

go
type EnvExtension struct{}

func (*EnvExtension) FuncMap

go
func (e *EnvExtension) FuncMap() template.FuncMap

func (*EnvExtension) Get

go
func (e *EnvExtension) Get(key string) string

type ErrorsxExtension

ErrorsxExtension is a template compatibility wrapper around existing errorsx zen package.

go
type ErrorsxExtension struct{}

func (*ErrorsxExtension) FuncMap

go
func (e *ErrorsxExtension) FuncMap() template.FuncMap

func (*ErrorsxExtension) Ignore

go
func (e *ErrorsxExtension) Ignore(val any, err error) any

func (*ErrorsxExtension) Must

go
func (e *ErrorsxExtension) Must(val any, err error) any

type FmtxExtension

AsyncExtension is a template compatibility wrapper around existing async zen package.

go
type FmtxExtension struct{}

func (*FmtxExtension) FuncMap

go
func (e *FmtxExtension) FuncMap() template.FuncMap

func (*FmtxExtension) Number

go
func (e *FmtxExtension) Number(number float64, precision int, prefix, suffix string) string

func (*FmtxExtension) NumberP0

go
func (e *FmtxExtension) NumberP0(number float64) string

func (*FmtxExtension) NumberP1

go
func (e *FmtxExtension) NumberP1(number float64) string

func (*FmtxExtension) Numeral

go
func (e *FmtxExtension) Numeral(number float64, precision int) string

func (*FmtxExtension) NumeralP0

go
func (e *FmtxExtension) NumeralP0(number float64) string

func (*FmtxExtension) NumeralP1

go
func (e *FmtxExtension) NumeralP1(number float64) string

type JsonxExtension

JsonxExtension is a template compatibility wrapper around existing jsonx zen package.

go
type JsonxExtension struct{}

func (*JsonxExtension) FuncMap

go
func (e *JsonxExtension) FuncMap() template.FuncMap

func (*JsonxExtension) String

go
func (e *JsonxExtension) String(value any) string

type MapxExtension

MapxExtension is a template compatibility wrapper around existing mapx zen package.

go
type MapxExtension struct{}

func (*MapxExtension) Compose

go
func (e *MapxExtension) Compose(vals ...any) map[any]any

func (*MapxExtension) FuncMap

go
func (e *MapxExtension) FuncMap() template.FuncMap

type MathxExtension

MathxExtension is a template compatibility wrapper around existing mathx zen package.

go
type MathxExtension struct{}

func (*MathxExtension) DivRuntime

go
func (e *MathxExtension) DivRuntime(vals ...any) any

func (*MathxExtension) FuncMap

go
func (e *MathxExtension) FuncMap() template.FuncMap

func (*MathxExtension) MulRuntime

go
func (e *MathxExtension) MulRuntime(vals ...any) any

func (*MathxExtension) SubRuntime

go
func (e *MathxExtension) SubRuntime(vals ...any) any

func (*MathxExtension) SumRuntime

go
func (e *MathxExtension) SumRuntime(vals ...any) any

type RegexpxExtension

RegexpxExtension is a template compatibility wrapper around existing regexpx zen package.

go
type RegexpxExtension struct{}

func (*RegexpxExtension) FuncMap

go
func (e *RegexpxExtension) FuncMap() template.FuncMap

func (*RegexpxExtension) Replace

go
func (e *RegexpxExtension) Replace(str, old, new string) string

type SliceExtension

SliceExtension is a template compatibility wrapper around existing slice zen package.

go
type SliceExtension struct{}

func (*SliceExtension) FuncMap

go
func (e *SliceExtension) FuncMap() template.FuncMap

func (*SliceExtension) In

go
func (e *SliceExtension) In(val any, sliceval any) bool

func (*SliceExtension) Range

go
func (e *SliceExtension) Range(from, to int) []int

type StringsExtension

StringsExtension is a template compatibility wrapper around existing string-related packages.

go
type StringsExtension struct{}

func (*StringsExtension) Contains

go
func (e *StringsExtension) Contains(str string, substr string) bool

func (*StringsExtension) FuncMap

go
func (e *StringsExtension) FuncMap() template.FuncMap

func (*StringsExtension) Lower

go
func (e *StringsExtension) Lower(str string) string

func (*StringsExtension) Replace

go
func (e *StringsExtension) Replace(str, old, new string) string

func (*StringsExtension) Sprintf

go
func (e *StringsExtension) Sprintf(format string, a ...any) string

func (*StringsExtension) Title

go
func (e *StringsExtension) Title(str string) string

func (*StringsExtension) Trim

go
func (e *StringsExtension) Trim(str string) string

func (*StringsExtension) Upper

go
func (e *StringsExtension) Upper(str string) string

type TimeExtension

TimeExtension is a template compatibility wrapper around existing time package.

go
type TimeExtension struct{}

func (*TimeExtension) FuncMap

go
func (e *TimeExtension) FuncMap() template.FuncMap

func (*TimeExtension) Now

go
func (e *TimeExtension) Now() time.Time

func (*TimeExtension) Nowfmt

go
func (e *TimeExtension) Nowfmt(format string) string

Generated by gomarkdoc