templateutils

package
v0.0.0-...-841f565 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ConvenienceFunctions = template.FuncMap{

	"base64Encode": base64.StdEncoding.EncodeToString,
	"base64Decode": base64.StdEncoding.DecodeString,
	"hexEncode":    hex.EncodeToString,
	"hexDecode":    hex.DecodeString,

	"basicAuth":     utils.BasicAuth,
	"bytesToString": utils.BytesToString,
	"stringToBytes": utils.StringToBytes,
	"encodeBytes":   utils.EncodeBytesToString,
	"decodeBytes":   utils.DecodeStringToBytes,
	"uuidv4":        utils.UUIDV4,
	"uuidV4":        utils.UUIDV4,
	"isoDateNow":    utils.ISODateNow,
	"join":          utils.JoinStrings,

	"md5":              cryptoutils.MD5Sum,
	"sha1":             cryptoutils.SHA1Sum,
	"sha256":           cryptoutils.SHA256Sum,
	"aes256CBCEncrypt": cryptoutils.AES256CBCEncrypt,
	"aes256CBCDecrypt": cryptoutils.AES256CBCDecrypt,
	"randIV":           cryptoutils.RandomIV,
	"hmac256":          cryptoutils.HMAC256Sum,
}

Functions

func RenderTemplateAsString

func RenderTemplateAsString(tmp *template.Template, data interface{}) (string, error)

RenderTemplateAsString executes a template and returns a string

Types

type ParseFunc

type ParseFunc func(body string) RenderFunc

ParseFunc is a function that accepts the body of a template and returns a core.RenderFunc

type RenderFunc

type RenderFunc func(data interface{}) (string, error)

RenderFunc is a function that accepts a template and its data, executes it and returns the string representation This is a convenience method to the standard template library which accepts an io.Writer instead of returning the rendered template

Jump to

Keyboard shortcuts

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