template

package
v0.0.0-...-5fbc178 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2023 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultFuncs = template.FuncMap{
	"toUpper": strings.ToUpper,
	"toLower": strings.ToLower,
	"title":   strings.Title,

	"join": func(sep string, s []string) string {
		return strings.Join(s, sep)
	},
	"match": regexp.MatchString,
	"safeHtml": func(text string) html.HTML {
		return html.HTML(text)
	},
	"reReplaceAll": func(pattern, repl, text string) string {
		re := regexp.MustCompile(pattern)
		return re.ReplaceAllString(text, repl)
	},
	"stringSlice": func(s ...string) []string {
		return s
	},
	"since": func(t time.Time) string {
		return durafmt.Parse(time.Since(t)).String()
	},
	"duration": func(start time.Time, end time.Time) string {
		return durafmt.Parse(end.Sub(start)).String()
	},
}

Functions

This section is empty.

Types

type Template

type Template struct {
	// contains filtered or unexported fields
}

func Default

func Default() *Template

func NewTemplate

func NewTemplate(t *template.Template) *Template

func Parse

func Parse(s string) (*Template, error)

func ParseFiles

func ParseFiles(path ...string) (*Template, error)

func (*Template) Produce

func (t *Template) Produce(m hook.Message) (string, error)

Jump to

Keyboard shortcuts

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