temple

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2024 License: Apache-2.0 Imports: 31 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DebugHTTPRequests     = false
	EnableUnsafeFunctions = false
)
View Source
var (
	FnMap = templeFnMap{
		"b64dec": {
			b64dec,
			"base64 decode",
			reflect.TypeOf(b64dec).String(),
			false,
		},
		"b64enc": {
			b64enc,
			"base64 encode",
			reflect.TypeOf(b64enc).String(),
			false,
		},
		"cmd": {
			cmd,
			"execute a command on local host",
			reflect.TypeOf(cmd).String(),
			true,
		},
		"decrypt": {
			decrypt,
			"decrypt data with AES_GCM: $1 ctxt, $2 base64 key, $3 AAD",
			reflect.TypeOf(decrypt).String(),
			false,
		},
		"duration": {
			time.ParseDuration,
			"time.ParseDuration",
			reflect.TypeOf(time.ParseDuration).String(),
			false,
		},
		"encrypt": {
			encrypt,
			"encrypt data with AES_GCM: $1 ptxt, $2 base64 key, $3 AAD",
			reflect.TypeOf(encrypt).String(),
			false,
		},
		"env": {
			env,
			"get environment vars, optionally use a placeholder value $2",
			reflect.TypeOf(env).String(),
			true,
		},
		"fns": {
			fns,
			"get list of available functions",
			reflect.TypeOf(fns).String(),
			false,
		},
		"fromgob": {
			fromgob,
			"gob decode",
			reflect.TypeOf(fromgob).String(),
			false,
		},
		"fromjson": {
			fromjson,
			"json decode",
			reflect.TypeOf(fromjson).String(),
			false,
		},
		"fromyaml": {
			fromyaml,
			"yaml decode",
			reflect.TypeOf(fromyaml).String(),
			false,
		},
		"gunzip": {
			_gunzip,
			"extract GZIP compressed data",
			reflect.TypeOf(_gunzip).String(),
			false,
		},
		"gzip": {
			_gzip,
			"compress with GZIP",
			reflect.TypeOf(_gzip).String(),
			false,
		},
		"hexdec": {
			hexdec,
			"hex decode",
			reflect.TypeOf(hexdec).String(),
			false,
		},
		"hexenc": {
			hexenc,
			"hex encode",
			reflect.TypeOf(hexenc).String(),
			false,
		},
		"http": {
			_http,
			"HEAD|GET|POST, url, body(raw), headers",
			reflect.TypeOf(_http).String(),
			true,
		},
		"is": {
			is,
			"check if $1 is all |upper(case), |lower(case), |int, |float, |float32, |bool or ==$2",
			reflect.TypeOf(is).String(),
			false,
		},
		"join": {
			strings.Join,
			"strings.Join",
			reflect.TypeOf(strings.Join).String(),
			false,
		},
		"lower": {
			strings.ToLower,
			"strings.ToLower",
			reflect.TypeOf(strings.ToLower).String(),
			false,
		},
		"math": {
			math,
			"math operations (+, -, *, /, %, max, min)",
			reflect.TypeOf(math).String(),
			false,
		},
		"mapadd": {
			add,
			"add value $2 to map or slice $1, map needs $3 for value's key in map",
			reflect.TypeOf(add).String(),
			false,
		},
		"pathbase": {
			filepath.Base,
			"filepath.Base",
			reflect.TypeOf(filepath.Base).String(),
			false,
		},
		"pathext": {
			filepath.Ext,
			"filepath.Ext",
			reflect.TypeOf(filepath.Ext).String(),
			false,
		},
		"random": {
			Random,
			"generate a $1 sized []byte filled with bytes from crypto.Rand",
			reflect.TypeOf(Random).String(),
			false,
		},
		"rawfile": {
			rawfile,
			"read raw bytes from a file",
			reflect.TypeOf(rawfile).String(),
			true,
		},
		"split": {
			strings.Split,
			"strings.Split",
			reflect.TypeOf(strings.Split).String(),
			false,
		},
		"string": {
			stringify,
			"convert int/bool to string, retype []byte to string (handle with care)",
			reflect.TypeOf(stringify).String(),
			false,
		},
		"textfile": {
			textfile,
			"read a file as a string",
			reflect.TypeOf(textfile).String(),
			true,
		},
		"timestamp": {
			timestamp,
			"$1 for timezone (default UTC)",
			reflect.TypeOf(timestamp).String(),
			false,
		},
		"togob": {
			togob,
			"gob encode",
			reflect.TypeOf(togob).String(),
			false,
		},
		"tojson": {
			tojson,
			"json encode",
			reflect.TypeOf(tojson).String(),
			false,
		},
		"toyaml": {
			toyaml,
			"yaml encode",
			reflect.TypeOf(toyaml).String(),
			false,
		},
		"trimprefix": {
			strings.TrimPrefix,
			"strings.TrimPrefix",
			reflect.TypeOf(strings.TrimPrefix).String(),
			false,
		},
		"trimsuffix": {
			strings.TrimSuffix,
			"strings.TrimSuffix",
			reflect.TypeOf(strings.TrimSuffix).String(),
			false,
		},
		"upper": {
			strings.ToUpper,
			"strings.ToUpper",
			reflect.TypeOf(strings.ToUpper).String(),
			false,
		},
		"userinput": {
			userinput,
			"get interactive user input (needs a terminal), if $2 bool is provided and true, term.ReadPassword is used. $1 is used as hint",
			reflect.TypeOf(userinput).String(),
			true,
		},
		"writefile": {
			writefile,
			"store data to a file (append if it already exists)",
			reflect.TypeOf(writefile).String(),
			true,
		},
	}
)
View Source
var (
	Tracking *sync.WaitGroup = &sync.WaitGroup{}
)

Functions

func Random

func Random(size int) (out []byte)

func RenderServer

func RenderServer(fnMap templeFnMap) http.HandlerFunc

func StartTracking

func StartTracking()

func StopTracking

func StopTracking()

func UIPage

func UIPage() http.HandlerFunc

Types

This section is empty.

Jump to

Keyboard shortcuts

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