transform

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Sep 9, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Dictionary

func Dictionary(values ...interface{}) (map[string]interface{}, error)

Dictionary creates a map[string]interface{} from the given parameters by walking the parameters and treating them as key-value pairs. The number of parameters must be even.

Copyright The Hugo Authors License Apache 2 https://github.com/spf13/hugo/blob/master/LICENSE.md https://github.com/spf13/hugo/blob/master/tpl/template_funcs.go

func MsToSeconds added in v1.0.3

func MsToSeconds(value interface{}) string

MsToSeconds converts a time in milliseconds to a representation in seconds. i.e. 147 milliseconds = 0.147

func NaturalTime

func NaturalTime(d time.Time) string

NaturalTime converts a time into a moment relative to now in human terms. i.e. `12 secondds ago` or `3 days from now`

func NumComma

func NumComma(value interface{}) string

NumComma takes a number and returns it comma delimited

If the value provided is not a number, an empty string is returned

func OrdToSuffix

func OrdToSuffix(value interface{}) string

OrdToSuffix takes an int, int32 or int64 and returns an nth English suffix

func Plural added in v1.0.2

func Plural(value interface{}, singular string, plural string) string

Plural takes a number and a singular word and pluralises using basic English rules. If the output is not as expected, provide the plural word too.

e.g. Plural(17, "record", "") = 17 records

func PluralWord added in v1.0.2

func PluralWord(value interface{}, singular string, plural string) string

PluralWord takes a number and a singular word and pluralises using basic English rules. If the output is not as expected, provide the plural word too.

e.g. PluralWord(17, "record", "") = records

func RFCTime

func RFCTime(d time.Time) string

RFCTime converts a time into the RFC3339 representation of that time for use in a HTML5 time element.

func SiSuffix added in v1.0.2

func SiSuffix(value interface{}) string

SiSuffix takes a number and returns an SI symbol as a suffix and the number rounded to 2 decimal places.

If the value provided is not a number, an empty string is returned

func Trunc

func Trunc(s string, i int) string

Trunc will shorten a string to fit within the given length and if shortened the string will end in ...

Types

This section is empty.

Jump to

Keyboard shortcuts

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