templateutil

package
v0.0.0-...-baf4ea5 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2021 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package templateutil provides various utility functions for golang templates

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Aan

func Aan(input string) string

Aan is a Template Function that returns "an" or "a" depending on whether the first letter of the string is a vowel. It defaults to "a"

func Funcs

func Funcs(funcs template.FuncMap) template.FuncMap

Funcs contains miscellaneous Template Functions

func InputDate

func InputDate(t sql.NullTime) (datestring string, err error)

func InputTime

func InputTime(t sql.NullTime) (timestring string, err error)

func Itoa

func Itoa(num interface{}) (string, error)

Itoa is a Template Function that converts a number into a string. If a string is provided, the string is simply returned

func JoinSet

func JoinSet(set map[string]bool, sep string) string

func JoinSlice

func JoinSlice(slice []string, sep string) string

func NullValue

func NullValue(x interface{}) string

NullValue returns either the underlying value of the sql Null type, or "<NULL>" if the value is null. If the underlying value is an empty string, a pair of escaped double quotes \"\" will be returned to signify an empty string.

func Sha1Hash

func Sha1Hash(inputs ...interface{}) (output string)

Sha1Hash is a Template Function that hashes a bunch of strings together using the SHA1 hash (the same that Git uses) and returns the first 8 characters from the hash

func Sql

func Sql(funcs template.FuncMap) template.FuncMap

Sql contains Template Functions for working with "database/sql" types

func Stringify

func Stringify(input interface{}) string

Stringify is a Template Function that converts a generic object into a JSON string. If the object cannot be marshalled into a json string, it returns "null" instead. To ensure that your object can be converted into json, make sure it has json struct tags on its fields

func Txt

func Txt(funcs template.FuncMap) template.FuncMap

Txt contains Template Functions that make text more presentable

Types

This section is empty.

Jump to

Keyboard shortcuts

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