funcmap

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 3, 2020 License: GPL-3.0 Imports: 12 Imported by: 5

README

funcmap

Build Status

Go template functions.

import "github.com/gomatic/funcmap"

...

template.New(name).
    Funcs(funcmap.Map).
    Parse(templateSource).
    Execute(&result, templateVariables)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Map = template.FuncMap{
	"debug":        debug,
	"debugging":    debugging,
	"debug_toggle": debug_toggle,
	"pause":        pause,
	"command_line": commandLine,
	"ip_math":      ip_math,
	"ip4_inc":      ip4_inc,
	"ip4_next":     ip4_next,
	"ip4_prev":     ip4_prev,
	"ip4_add":      ip4_add,
	"ip4_join":     ip4_join,
	"ip6_inc":      ip6_inc,
	"ip6_next":     ip6_next,
	"ip6_prev":     ip6_prev,
	"ip6_add":      ip6_add,
	"ip6_join":     ip6_join,
	"cidr_next":    cidr_next,
	"ip_ints":      ip_ints,
	"ip_split":     ip_split,
	"to_int":       to_int,
	"dec_to_int":   dec_to_int,
	"hex_to_int":   hex_to_int,
	"from_int":     from_int,
	"next":         next,
	"keynext":      keynext,
	"inc":          step,
	"add":          add,
	"sub":          sub,
	"mul":          mul,
	"div":          div,
	"mod":          mod,
	"rand":         func() int64 { return rand.Int63() },
	"identifier":   cleanse(`^[^[:alpha:]_]+|[^[:alnum:]_]`),
	"cleanse":      cleanse(`[^[:alpha:]]`),
	"cleanser":     cleanser,
	"environment":  environment,
	"now":          privateTime.Now,
	"started":      started(),
	"iindex":       index,
	"split":        split,
	"join":         join,
	"substr":       substr,
	"lower":        strings.ToLower,
	"replace":      strings.Replace,
	"replace_":     func(n int, old, new, s string) string { return strings.Replace(s, old, new, n) },
	"title":        strings.Title,
	"initcap":      func(s string) string { return strings.Title(strings.ToLower(s)) },
	"trim":         strings.Trim,
	"trim_":        func(cut, s string) string { return strings.Trim(s, cut) },
	"trim_left":    strings.TrimLeft,
	"trim_left_":   func(cut, s string) string { return strings.TrimLeft(s, cut) },
	"trim_right":   strings.TrimRight,
	"trim_right_":  func(cut, s string) string { return strings.TrimRight(s, cut) },
	"upper":        strings.ToUpper,
	"basename":     basename,
	"dirname":      filepath.Dir,
	"ext":          filepath.Ext,
}

Functions

func UseClock

func UseClock(c clock.Clock)

func UseTime

func UseTime(t clock.TimeFunction)

Types

This section is empty.

Jump to

Keyboard shortcuts

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