wd_template

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Apr 21, 2024 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	RenderStatusShow = "success"
	RenderStatusHide = "failure"
)

Variables

View Source
var (
	DefaultHelpers = map[string]interface{}{
		"duration":       toDuration,
		"datetime":       toDatetime,
		"success":        isSuccess,
		"failure":        isFailure,
		"truncate":       truncate,
		"urlencode":      urlencode,
		"since":          since,
		"uppercasefirst": uppercaseFirst,
		"uppercase":      strings.ToUpper,
		"lowercase":      strings.ToLower,
		"regexReplace":   regexReplace,
	}
)

Functions

func RegisterSettings

func RegisterSettings(funcSettings map[string]interface{})

RegisterSettings most of this can use wd_template.RegisterSettings(DefaultFunctions)

func Render

func Render(template string, payload interface{}) (s string, errOut error)

Render parses and executes a template, returning the results in string format. Trailing or leading spaces or new-lines are not getting truncated. It is able to read templates from remote paths, local files or directly from the string. please use wd_template.RegisterSettings(DefaultFunctions) once to use.

func RenderTrim

func RenderTrim(template string, payload interface{}) (string, error)

RenderTrim parses and executes a template, returning the results in string format. The result is trimmed to remove left and right padding and newlines that may be added unintentially in the template markup. please use wd_template.RegisterSettings(DefaultFunctions) once to use.

Types

This section is empty.

Jump to

Keyboard shortcuts

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