Get startedSign in

Supported Liquid Filters

abbrev

Truncates a string with ellipses.

Parameters:

  • Max length

  • String to truncate

Example: abbrev 5 "hello world" returns he....

Implementation: github.com/Masterminds/sprig/v3.abbrev

abbrevboth

Truncates both sides of a string with ellipses.

Parameters:

  • Left offset

  • Max length

  • String to truncate

Example: abbrevboth 5 10 "1234 5678 9123" returns ...5678....

Implementation: github.com/Masterminds/sprig/v3.abbrevboth

add

Sums numbers. Accepts two or more inputs.

Parameters:

  • Number to add

  • Number to add

  • ...

Example: add 1 2 3 returns 6.

Implementation: github.com/Masterminds/sprig/v3.init.func15

add1

Increments by 1.

Parameters:

  • Number to increment

Example: add1 3 returns 4.

Implementation: github.com/Masterminds/sprig/v3.init.func14

add1f

Increments float number by 1.

Parameters:

  • Float number to increment

Example: add1 3.0 returns 4.0.

Implementation: github.com/Masterminds/sprig/v3.init.func21

addf

Sums float numbers. Accepts two or more inputs.

Parameters:

  • Float number

  • Float number

  • ...

Example: add 1.1 2.2 3.3 returns 6.6.

Implementation: github.com/Masterminds/sprig/v3.init.func22

adler32sum

Computes Adler-32 checksum of a string.

Parameters:

  • String

Example: adler32sum "Hello world!".

Implementation: github.com/Masterminds/sprig/v3.adler32sum

ago

Returns duration from current time (time.Now) in seconds resolution.

Parameters:

  • Date

Example: ago .CreatedAt will return something like 2h34m7s.

Implementation: github.com/Masterminds/sprig/v3.dateAgo

all

Takes a list of values ad returns true if all values are non-empty.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.all

any

Takes a list of values ad returns true if any values are non-empty.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.any

append

Appends a new item to existing list, creating a new list.

Parameters:

  • List

  • Item to append

Example: append ( list 1 2 3 ) 5 returns [1, 2, 3, 5].

Implementation: github.com/Masterminds/sprig/v3.push

atoi

Converts a string to an integer.

Parameters:

  • String to convert

Implementation: github.com/Masterminds/sprig/v3.init.func12

b32dec

Decodes string from Base32 format.

Parameters:

  • String to decode

Implementation: github.com/Masterminds/sprig/v3.base32decode

b32enc

Encodes string with Base32 format.

Parameters:

  • String to encode

Implementation: github.com/Masterminds/sprig/v3.base32encode

b64dec

Decodes string from Base64 format.

Parameters:

  • String to decode

Implementation: github.com/Masterminds/sprig/v3.base64decode

b64enc

Encodes string with Base64 format.

Parameters:

  • String to encode

Implementation: github.com/Masterminds/sprig/v3.base64encode

base

Returns the last element of a path.

Parameters:

  • Path

Example: base "foo/bar/baz" returns baz.

Implementation: path.Base

bcrypt

Generates bcrypt hash of a string.

Parameters:

  • String

Implementation: github.com/Masterminds/sprig/v3.bcrypt

biggest

Implementation: github.com/Masterminds/sprig/v3.max

buildCustomCert

Allows customizing the certificate. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the genSignedCert function to sign a certificate using this CA.

Parameters:

  • Base64 encoded PEM format certificate

  • Base64 encoded PEM format private key

Example: $ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-key"

Implementation: github.com/Masterminds/sprig/v3.buildCustomCertificate

camelcase

Converts a string from snake_case to camelCase.

Parameters:

  • String to convert

Example: camelcase "http_server" returns HttpServer.

Implementation: github.com/huandu/xstrings.ToPascalCase

cat

Implementation: github.com/Masterminds/sprig/v3.cat

ceil

Returns greatest float value greater than or equal to input value.

Parameters:

  • Input value

Example: ceil 123.001 will return 124.0.

Implementation: github.com/Masterminds/sprig/v3.ceil

chunk

Implementation: github.com/Masterminds/sprig/v3.chunk

clean

Implementation: path.Clean

coalesce

Implementation: github.com/Masterminds/sprig/v3.coalesce

compact

Accepts a list and removes entries with empty values.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.compact

concat

Concatenates arbitrary number of lists into one.

Parameters:

  • List

  • ...

Implementation: github.com/Masterminds/sprig/v3.concat

contains

Tests if one string is contained inside of another.

Parameters:

  • Substring

  • String

Example: contains "cat" "catch" returns true.

Implementation: github.com/Masterminds/sprig/v3.init.func9

date

Formats date. See https://pauladamsmith.com/blog/2011/05/go_time.html.

Parameters:

  • Date layout

Implementation: github.com/Masterminds/sprig/v3.date

dateInZone

Same as date but with a timezone.

Parameters:

  • Date layout

  • Date to format

  • Timezone

Example: dateInZone "2006-01-02" (now) "UTC".

Aliases: date_in_zone
Implementation: github.com/Masterminds/sprig/v3.dateInZone

dateModify

Allows date modifications.

Parameters:

  • Date modification

  • Date

Example: now | dateModify "-1.5h" will subtract an hour and thirty minutes from the current time.

Aliases: date_modify
Implementation: github.com/Masterminds/sprig/v3.dateModify

decryptAES

Receives a Base64 string encoded by the AES-256 CBC algorithm and returns the decoded text.

Parameters:

  • Base64 string encoded by the AES-256 CBC algorithm

Implementation: github.com/Masterminds/sprig/v3.decryptAES

deepCopy

Makes deep copy of the value. This includes maps and other structures. It will panic if there is a problem.

Parameters:

  • Value to copy

Example: dict "a" 1 "b" 2 | deepCopy.

Implementation: github.com/Masterminds/sprig/v3.deepCopy

deepEqual

Implementation: reflect.DeepEqual

default

Implementation: github.com/pluralsh/polly/template.dfault

derivePassword

Implementation: github.com/Masterminds/sprig/v3.derivePassword

dict

Implementation: github.com/Masterminds/sprig/v3.dict

dig

Implementation: github.com/Masterminds/sprig/v3.dig

dir

Implementation: path.Dir

div

Performs integer division.

Implementation: github.com/Masterminds/sprig/v3.init.func17

divf

Performs float number division.

Implementation: github.com/Masterminds/sprig/v3.init.func24

duration

Formats a given amount of seconds as a time.Duration.

Parameters:

  • Amount of seconds

Example: duration "95" returns 1m35s.

Implementation: github.com/Masterminds/sprig/v3.duration

durationRound

Implementation: github.com/Masterminds/sprig/v3.durationRound

empty

Returns true if given value has the zero value for its type.

Parameters:

  • Value

Example: empty .Foo.

Implementation: github.com/Masterminds/sprig/v3.empty

encryptAES

Encrypts text with AES-256 CBC and returns a Base64 encoded string.

Parameters:

  • Secret key

  • Text to encrypt

Example: encryptAES "secretkey" "plaintext".

Implementation: github.com/Masterminds/sprig/v3.encryptAES

env

Reads environment variable.

Parameters:

  • Environment variable name

Example: env "HOME"

Implementation: os.Getenv

expandenv

Substitutes environment variable in a string.

Parameters:

  • String to expand

Example: expandenv "Your path is set to $PATH"

Implementation: os.ExpandEnv

ext

Returns file extension.

Parameters:

  • File path

Example: ext "foo.bar" will return "bar"

Implementation: path.Ext

fail

Unconditionally returns an empty string and an error with the specified text. This is useful in scenarios where other conditionals have determined that template rendering should fail.

Parameters:

  • Error message

Example: fail "Please accept the end user license agreement"

Implementation: github.com/Masterminds/sprig/v3.init.func26

first

Returns head item on a list.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.first

float64

Converts to a float64

Parameters:

  • Value to convert, it can be for example an integer or a string

Implementation: github.com/Masterminds/sprig/v3.toFloat64

floor

Returns the greatest float value greater than or equal to input value.

Parameters:

  • Input value

Example: floor 123.9999 will return 123.0

Implementation: github.com/Masterminds/sprig/v3.floor

fromJson

Decodes a JSON document into a structure. If the input cannot be decoded as JSON the function will return an empty string.

Parameters:

  • JSON document

Example: fromJson "{\"foo\": 55}".

Aliases: from_json
Implementation: github.com/Masterminds/sprig/v3.fromJson

genCA

Generates a new, self-signed x509 SSL Certificate Authority using 2048-bit RSA private key. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the genSignedCert function to sign a certificate using this CA.

Parameters:

  • Subject common name (CN)

  • Cert validity duration in days

Implementation: github.com/Masterminds/sprig/v3.generateCertificateAuthority

genCAWithKey

Generates a new, self-signed x509 SSL Certificate Authority using given private key. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the genSignedCert function to sign a certificate using this CA.

Parameters:

  • Subject common name (CN)

  • Cert validity duration in days

  • private key (PEM-encoded; DSA keys are not supported)

Implementation: github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey

genPrivateKey

Generates a new private key encoded into a PEM block.

Parameters:

  • Key type (ecdsa, dsa, rsa or ed25519)

Implementation: github.com/Masterminds/sprig/v3.generatePrivateKey

genSelfSignedCert

Generates an SSL self-signed certificate.

Implementation: github.com/Masterminds/sprig/v3.generateSelfSignedCertificate

genSelfSignedCertWithKey

Implementation: github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey

genSignedCert

Generates an SSL certificate and key based on a given CA.

Implementation: github.com/Masterminds/sprig/v3.generateSignedCertificate

genSignedCertWithKey

Implementation: github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey

get

Implementation: github.com/Masterminds/sprig/v3.get

getHostByName

Implementation: github.com/Masterminds/sprig/v3.getHostByName

has

Checks if a list has a particular element. It will panic if there is a problem.

Parameters:

  • Element to find

  • List

Example: has 4 $myList

Implementation: github.com/Masterminds/sprig/v3.has

hasKey

Checks if given dictionary contains given key.

Parameters:

  • Map

  • Key to find

Implementation: github.com/Masterminds/sprig/v3.hasKey

hasPrefix

Check if string has given prefix.

Parameters:

  • Prefix

  • String

Implementation: github.com/Masterminds/sprig/v3.init.func10

hasSuffix

Check if string has given suffix.

Parameters:

  • Prefix

  • Suffix

Implementation: github.com/Masterminds/sprig/v3.init.func11

htmlDate

Formats a date for inserting into HTML date picker input field.

Parameters:

  • Date

Example: now | htmlDate.

Implementation: github.com/Masterminds/sprig/v3.htmlDate

htmlDateInZone

Same as htmlDate but with a timezone.

Parameters:

  • Date

  • Timezone

Example: htmlDateInZone (now) "UTC".

Implementation: github.com/Masterminds/sprig/v3.htmlDateInZone

htpasswd

Implementation: github.com/Masterminds/sprig/v3.htpasswd

indent

Implementation: github.com/pluralsh/polly/template.indent

initial

Compliments last by retuning all but the last element. It will panic if there is a problem.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.initial

initials

Implementation: github.com/Masterminds/sprig/v3.initials

int

Converts to a int.

Parameters:

  • Value to convert

Implementation: github.com/Masterminds/sprig/v3.toInt

int64

Converts to a int64.

Parameters:

  • Value to convert

Implementation: github.com/Masterminds/sprig/v3.toInt64

isAbs

Checks whether a path is absolute.

Parameters:

  • File path

Implementation: path.IsAbs

join

Implementation: github.com/Masterminds/sprig/v3.join

kebabcase

Converts a string from camelCase to kebab-case.

Parameters:

  • String to convert

Example: kebabcase "FirstName" returns first-name.

Implementation: github.com/huandu/xstrings.ToKebabCase

keys

Returns list of all keys from a map.

Parameters:

  • Map

Implementation: github.com/Masterminds/sprig/v3.keys

kindIs

Implementation: github.com/Masterminds/sprig/v3.kindIs

kindOf

Implementation: github.com/Masterminds/sprig/v3.kindOf

last

Implementation: github.com/Masterminds/sprig/v3.last

list

Implementation: github.com/Masterminds/sprig/v3.list

lower

Converts the entire string to lowercase.

Parameters:

  • String to transform

Example: upper \"HELLO\" will return hello.

Implementation: strings.ToLower

max

Returns the largest of a series of integers.

Parameters:

  • Number

  • Number

  • ...

Example: max 1 2 3 will return 3.

Implementation: github.com/Masterminds/sprig/v3.max

maxf

Returns the largest of a series of floats.

Parameters:

  • Float number

  • Float number

  • ...

Example: max 1 2 3.65 will return 3.65.

Implementation: github.com/Masterminds/sprig/v3.maxf

merge

Implementation: github.com/Masterminds/sprig/v3.merge

mergeOverwrite

Implementation: github.com/Masterminds/sprig/v3.mergeOverwrite

min

Returns the smallest of a series of integers.

Parameters:

  • Number

  • Number

  • ...

Example: min 1 2 3 will return 1.

Implementation: github.com/Masterminds/sprig/v3.min

minf

Returns the smallest of a series of floats.

Parameters:

  • Float number

  • Float number

  • ...

Example: min 1.3 2 3 will return 1.3.

Implementation: github.com/Masterminds/sprig/v3.minf

mod

Implementation: github.com/Masterminds/sprig/v3.init.func18

mul

Multiplies numbers. Accepts two or more inputs.

Parameters:

  • Number

  • Number

  • ...

Example: mul 1 2 3 will return 6.

Implementation: github.com/Masterminds/sprig/v3.init.func19

mulf

Multiplies float numbers. Accepts two or more inputs.

Parameters:

  • Float number

  • Float number

  • ...

Example: mulf 1.5 2 2 returns 6.

Implementation: github.com/Masterminds/sprig/v3.init.func25

mustAppend

Appends a new item to existing list, creating a new list. It will return an error to the template engine if there is a problem.

Parameters:

  • List

  • Item to append

Example: mustAppend ( list 1 2 3 ) 5 returns [1, 2, 3, 5].

Implementation: github.com/Masterminds/sprig/v3.mustPush

mustChunk

Implementation: github.com/Masterminds/sprig/v3.mustChunk

mustCompact

Accepts a list and removes entries with empty values. It will return an error to the template engine if there is a problem.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.mustCompact

mustDateModify

Aliases: must_date_modify
Implementation: github.com/Masterminds/sprig/v3.mustDateModify

mustDeepCopy

Implementation: github.com/Masterminds/sprig/v3.mustDeepCopy

mustFirst

Returns head item on a list. It will return an error to the template engine if there is a problem.

Parameters:

  • List

Example: mustFirst $myList

Implementation: github.com/Masterminds/sprig/v3.mustFirst

mustFromJson

Implementation: github.com/Masterminds/sprig/v3.mustFromJson

mustHas

Checks if a list has a particular element. It will return an error to the template engine if there is a problem.

Parameters:

  • Element to find

  • List

Example: mustHas 4 $myList

Implementation: github.com/Masterminds/sprig/v3.mustHas

mustInitial

Compliments last by retuning all but the last element. It will return an error to the template engine ifd there is a problem.

Parameters:

  • List

Example: mustInitial $myList

Implementation: github.com/Masterminds/sprig/v3.mustInitial

mustLast

Implementation: github.com/Masterminds/sprig/v3.mustLast

mustMerge

Implementation: github.com/Masterminds/sprig/v3.mustMerge

mustMergeOverwrite

Implementation: github.com/Masterminds/sprig/v3.mustMergeOverwrite

mustPrepend

Implementation: github.com/Masterminds/sprig/v3.mustPrepend

mustPush

Implementation: github.com/Masterminds/sprig/v3.mustPush

mustRegexFind

Implementation: github.com/Masterminds/sprig/v3.mustRegexFind

mustRegexFindAll

Implementation: github.com/Masterminds/sprig/v3.mustRegexFindAll

mustRegexMatch

Implementation: github.com/Masterminds/sprig/v3.mustRegexMatch

mustRegexReplaceAll

Implementation: github.com/Masterminds/sprig/v3.mustRegexReplaceAll

mustRegexReplaceAllLiteral

Implementation: github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral

mustRegexSplit

Implementation: github.com/Masterminds/sprig/v3.mustRegexSplit

mustRest

Gets tail of the list (everything but the first item). It will return an error to the template engine if there is a problem.

Parameters:

  • List

Example: mustRest $myList

Implementation: github.com/Masterminds/sprig/v3.mustRest

mustReverse

Produces a new list with the reversed elements of the given list. It will return an error to the template engine if there is a problem.

Parameters:

  • List

Example: mustReverse $myList

Implementation: github.com/Masterminds/sprig/v3.mustReverse

mustSlice

Implementation: github.com/Masterminds/sprig/v3.mustSlice

mustToDate

Converts a string to a date. If the string can’t be converted it returns the zero value. It will return an error to the template engine if there is a problem.

Parameters:

  • Date layout

  • Date string

Implementation: github.com/Masterminds/sprig/v3.mustToDate

mustToJson

Implementation: github.com/Masterminds/sprig/v3.mustToJson

mustToPrettyJson

Implementation: github.com/Masterminds/sprig/v3.mustToPrettyJson

mustToRawJson

Implementation: github.com/Masterminds/sprig/v3.mustToRawJson

mustUniq

Generates a list with all of the duplicates removed. It will return an error to the template engine if there is a problem.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.mustUniq

mustWithout

Filters items out of a list. It will return an error to the template engine if there is a problem.

Parameters:

  • CList

  • Item to filter out

Example: mustWithout ( list 1 2 3 4 5) 1 3 5 returns [2, 4].

Implementation: github.com/Masterminds/sprig/v3.mustWithout

nindent

Implementation: github.com/pluralsh/polly/template.nindent

nospace

Removes all whitespace from a string.

Parameters:

  • String to transform

Example: nospace "hello w o r l d" will return helloworld.

Implementation: github.com/Masterminds/goutils.DeleteWhiteSpace

omit

Implementation: github.com/Masterminds/sprig/v3.omit

osBase

Returns the last element of a file path.

Parameters:

  • File path

Example: osClean "/foo/bar/../baz" and osClean "C:\\foo\\bar\\..\\baz" will resolve the .. and return foo/baz on Linux and C:\foo\baz on Windows.

Implementation: path/filepath.Base

osClean

Cleans up a path.

Parameters:

  • File path

Example: osClean "/foo/bar/../baz" and osClean "C:\\foo\\bar\\..\\baz" will resolve the .. and return foo/baz on Linux and C:\foo\baz on Windows.

Implementation: path/filepath.Clean

osDir

Returns the directory, stripping the last part of the path.

Parameters:

  • File path

Example: osDir "/foo/bar/baz" returns /foo/bar on Linux, and osDir "C:\\foo\\bar\\baz" returns C:\\foo\\bar on Windows.

Implementation: path/filepath.Dir

osExt

Return the file extension.

Parameters:

  • File path

Example: osExt "/foo.bar" and osExt "C:\\foo.bar" will return .bar on Linux and Windows, respectively.

Implementation: path/filepath.Ext

osIsAbs

Checks whether a file path is absolute.

Parameters:

  • File path

Implementation: path/filepath.IsAbs

pick

Implementation: github.com/Masterminds/sprig/v3.pick

pluck

Implementation: github.com/Masterminds/sprig/v3.pluck

plural

Implementation: github.com/Masterminds/sprig/v3.plural

prepend

Implementation: github.com/Masterminds/sprig/v3.prepend

push

Implementation: github.com/Masterminds/sprig/v3.push

quote

Implementation: github.com/Masterminds/sprig/v3.quote

randAlpha

Implementation: github.com/Masterminds/sprig/v3.randAlpha

randAlphaNum

Implementation: github.com/Masterminds/sprig/v3.randAlphaNumeric

randAscii

Implementation: github.com/Masterminds/sprig/v3.randAscii

randBytes

Accepts a count and generates cryptographically secure random sequence of bytes. The sequence is returned as a Base64 encoded string.

Parameters:

  • Number of bytes to generate

Implementation: github.com/Masterminds/sprig/v3.randBytes

randInt

Returns a random integer value from min (inclusive) to max (exclusive).

Parameters:

  • Min value (inclusive)

  • Max value (exclusive)

Example: randInt 12 30 will produce a random number in the range from 12 to 30.

Implementation: github.com/Masterminds/sprig/v3.init.func20

randNumeric

Implementation: github.com/Masterminds/sprig/v3.randNumeric

regexFind

Implementation: github.com/Masterminds/sprig/v3.regexFind

regexFindAll

Implementation: github.com/Masterminds/sprig/v3.regexFindAll

regexMatch

Implementation: github.com/Masterminds/sprig/v3.regexMatch

regexQuoteMeta

Implementation: github.com/Masterminds/sprig/v3.regexQuoteMeta

regexReplaceAll

Implementation: github.com/Masterminds/sprig/v3.regexReplaceAll

regexReplaceAllLiteral

Implementation: github.com/Masterminds/sprig/v3.regexReplaceAllLiteral

regexSplit

Implementation: github.com/Masterminds/sprig/v3.regexSplit

repeat

Implementation: github.com/Masterminds/sprig/v3.init.func2

replace

Implementation: strings.ReplaceAll

rest

Gets tail of the list (everything but the first item).

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.rest

reverse

Produces a new list with the reversed elements of the given list.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.reverse

round

Returns a float value with the remainder rounded to the given number to digits after the decimal point.

Parameters:

  • Float number

  • Number of digits to round to

Example: round 123.55555 3 will return 123.556.

Implementation: github.com/Masterminds/sprig/v3.round

semver

Implementation: github.com/Masterminds/sprig/v3.semver

semverCompare

Aliases: semver_compare
Implementation: github.com/Masterminds/sprig/v3.semverCompare

seq

Works like Bash seq command. Specify 1 parameter (end) to generate all counting integers between 1 and end inclusive. Specify 2 parameters (start and end) to generate all counting integers between start and end inclusive incrementing or decrementing by 1. Specify 3 parameters (start, step and end) to generate all counting integers between start and end inclusive incrementing or decrementing by step.

Implementation: github.com/Masterminds/sprig/v3.seq

set

Implementation: github.com/Masterminds/sprig/v3.set

sha1sum

Implementation: github.com/Masterminds/sprig/v3.sha1sum

sha256sum

Generates SHA256 hash of an input.

Parameters:

  • Input value

Aliases: sha26sum
Implementation: github.com/Masterminds/sprig/v3.sha256sum

sha512sum

Generates SHA512 hash of an input.

Parameters:

  • Input value

Example: sha512sum "Hello world!".

Implementation: github.com/Masterminds/sprig/v3.sha512sum

shuffle

Shuffles a string.

Parameters:

  • String to shuffle

Example: shuffle "hello".

Implementation: github.com/huandu/xstrings.Shuffle

slice

Implementation: github.com/Masterminds/sprig/v3.slice

snakecase

Converts a string from camelCase to snake_case.

Parameters:

  • String to convert

Example: camelcase "FirstName" returns first_name.

Implementation: github.com/huandu/xstrings.ToSnakeCase

sortAlpha

Implementation: github.com/Masterminds/sprig/v3.sortAlpha

split

Implementation: github.com/Masterminds/sprig/v3.split

splitList

Implementation: github.com/Masterminds/sprig/v3.init.func13

splitn

Implementation: github.com/Masterminds/sprig/v3.splitn

squote

Implementation: github.com/Masterminds/sprig/v3.squote

sub

Implementation: github.com/Masterminds/sprig/v3.init.func16

subf

Implementation: github.com/Masterminds/sprig/v3.init.func23

substr

Implementation: github.com/Masterminds/sprig/v3.substring

swapcase

Swaps the case of a string using a word based algorithm.

Parameters:

  • String to convert

Example: swapcase "This Is A.Test" returns tHIS iS a.tEST.

Implementation: github.com/Masterminds/goutils.SwapCase

ternary

Takes two values and a test value. If the test value is true, the first value will be returned. If the test value is false, the second value will be returned. This is similar to the C ternary operator.

Parameters:

  • First value

  • Second value

  • Test value

Example: ternary "foo" "bar" true or true | "foo" "bar" will return "foo".

Implementation: github.com/pluralsh/polly/template.ternary

title

Converts a string to title case.

Parameters:

  • String

Example: title "hello world" returns "Hello World".

Implementation: strings.Title

toDate

Converts a string to a date. If the string can’t be converted it returns the zero value.

Parameters:

  • Date layout

  • Date string

Implementation: github.com/Masterminds/sprig/v3.toDate

toDecimal

Converts a Unix octal to a int64.

Parameters:

  • Unix octal

Example: "0777" | toDecimal will convert 0777 to 511 and return the value as int64.

Implementation: github.com/Masterminds/sprig/v3.toDecimal

toJson

Encodes an item into JSON string. If the item cannot be converted to JSON the function will return an empty string.

Parameters:

  • An item to encode

Example: toJson .Item returns JSON string representation of .Item.

Aliases: to_json
Implementation: github.com/Masterminds/sprig/v3.toJson

toPrettyJson

Encodes an item into pretty (intended) JSON string.

Parameters:

  • An item to encode

Example: toPrettyJson .Item returns intended JSON string representation of .Item.

Implementation: github.com/Masterminds/sprig/v3.toPrettyJson

toRawJson

Encodes an item into JSON string with HTML characters unescaped.

Parameters:

  • An item to encode

Example: toRawJson .Item returns unescaped JSON string representation of .Item.

Implementation: github.com/Masterminds/sprig/v3.toRawJson

toString

Converts to a string.

Parameters:

  • Value

Implementation: github.com/Masterminds/sprig/v3.strval

toStrings

Converts a list, slice or array to a list of strings.

Parameters:

  • List

Example: list 1 2 3 | toString converts 1, 2 and 3 to strings and then returns them as a list.

Implementation: github.com/Masterminds/sprig/v3.strslice

trim

Removes space from either side of a string.

Parameters:

  • String to trim

Example: trim " hello " will return hello.

Implementation: strings.TrimSpace

trimAll

Removes given characters from the front or back of a string.

Parameters:

  • Character to remove

  • String to trim

Example: trimAll "$" "$5.00" will return 5.00 (as a string).

Implementation: github.com/Masterminds/sprig/v3.init.func4

trimPrefix

Trims just the prefix from a string.

Parameters:

  • Character to remove

  • String to trim

Example: trimPrefix "-" "-hello" will return hello.

Implementation: github.com/Masterminds/sprig/v3.init.func6

trimSuffix

Trims just the suffix from a string.

Parameters:

  • Character to remove

  • String to trim

Example: trimSuffix "-" "hello-" will return hello.

Implementation: github.com/Masterminds/sprig/v3.init.func5

trimall

Implementation: github.com/Masterminds/sprig/v3.init.func3

trunc

Implementation: github.com/Masterminds/sprig/v3.trunc

tuple

Implementation: github.com/Masterminds/sprig/v3.list

typeIs

Implementation: github.com/Masterminds/sprig/v3.typeIs

typeIsLike

Implementation: github.com/Masterminds/sprig/v3.typeIsLike

typeOf

Implementation: github.com/Masterminds/sprig/v3.typeOf

uniq

Generates a list with all of the duplicates removed.

Parameters:

  • List

Implementation: github.com/Masterminds/sprig/v3.uniq

unixEpoch

Returns the seconds since the Unix epoch for a time.

Parameters:

  • Time (time.Time)

Example: now | unixEpoch

Implementation: github.com/Masterminds/sprig/v3.unixEpoch

unset

Given a map and a key it deletes the key from the map. It returns dictionary. Note that if the key is not found this operation will simply return. No error will be generated.

Parameters:

  • Map

  • Key of an item to delete

Implementation: github.com/Masterminds/sprig/v3.unset

until

Builds a range of integers.

Parameters:

  • Max value (exclusive)

Example: until 5 will return a list [0, 1, 2, 3, 4].

Implementation: github.com/Masterminds/sprig/v3.until

untilStep

Like until generates a list of counting integers but it allows to define a start, stop and step.

Parameters:

  • Start value (inclusive)

  • Max value (exclusive)

  • Step

Example: untilStep 3 6 2 will return [3, 5] by starting with 3 and adding 2 until it is equal or greater than 6.

Implementation: github.com/Masterminds/sprig/v3.untilStep

untitle

Removes title casing.

Parameters:

  • String to transform

Example: untitle "Hello World" returns "hello world".

Implementation: github.com/Masterminds/sprig/v3.untitle

upper

Converts the entire string to uppercase.

Parameters:

  • String to transform

Example: upper "hello" returns HELLO

Implementation: strings.ToUpper

urlJoin

Joins map produced by urlParse to produce URL string.

Parameters:

  • Map produced by urlParse

Example: urlJoin (dict "fragment" "fragment" "host" "host:80" "path" "/path" "query" "query" "scheme" "http") returns proto://host:80/path?query#fragment.

Implementation: github.com/Masterminds/sprig/v3.urlJoin

urlParse

Parses string for URL and produces dict with URL parts. For more info check https://golang.org/pkg/net/url/#URL.

Parameters:

  • String with URL

Implementation: github.com/Masterminds/sprig/v3.urlParse

values

Returns list of all values from a map.

Parameters:

  • Map

Implementation: github.com/Masterminds/sprig/v3.values

without

Filters items out of a list. It can take more than one filter.

Parameters:

  • List

  • Item to filter out

Example: without ( list 1 2 3 4 5) 1 3 5 returns [2, 4].

Implementation: github.com/Masterminds/sprig/v3.without

wrap

Wraps text at a given column count.

Parameters:

  • Column count

  • Text

Example: wrap 80 $text will wrap the string in $text at 80 columns.

Implementation: github.com/Masterminds/sprig/v3.init.func7

wrapWith

Works as wrap but lets you specify the string to wrap with (wrap uses \n).

Parameters:

  • Column count

  • String to wrap with

  • Text

Example: wrapWith 5 "\t" "Hello world" returns hello world (where the whitespace is an ASCII tab character).

Implementation: github.com/Masterminds/sprig/v3.init.func8