diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index e4cf370..f3d154b 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -1,1457 +1,2879 @@ # Supported Liquid Filters -## abbrev +## `abbrev` +Truncates a string with ellipses. +_Parameters_: +- Max length -_Implementation_: github.com/Masterminds/sprig/v3.abbrev +- String to truncate -## abbrevboth +_Example_: `abbrev 5 "hello world"` returns `he...`. -_Implementation_: github.com/Masterminds/sprig/v3.abbrevboth -## add -Sums numbers. Accepts two or more inputs. `add 1 2 3` will return `6`. +_Implementation_: `github.com/Masterminds/sprig/v3.abbrev` +## `abbrevboth` +Truncates both sides of a string with ellipses. -_Implementation_: github.com/Masterminds/sprig/v3.init.func15 -## add1 -Increments by 1. `add1 3` will return `4`. +_Parameters_: +- Left offset +- Max length -_Implementation_: github.com/Masterminds/sprig/v3.init.func14 +- String to truncate -## add1f + + + +_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 -_Implementation_: github.com/Masterminds/sprig/v3.init.func21 -## addf -Sums float numbers. +_Example_: `add1 3.0` returns `4.0`. -_Implementation_: github.com/Masterminds/sprig/v3.init.func22 -## adler32sum -Receives a string and computes its Adler-32 checksum. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func21` +## `addf` +Sums float numbers. Accepts two or more inputs. -_Implementation_: github.com/Masterminds/sprig/v3.adler32sum -## ago -Returns duration from current time in seconds resolution. +_Parameters_: +- Float number +- Float number -_Implementation_: github.com/Masterminds/sprig/v3.dateAgo +- ... -## all + + + +_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 + + +_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 +_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 +_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 + + +_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 + + + + +_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 + + +_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 +_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.base64encode -## base +_Implementation_: `github.com/Masterminds/sprig/v3.bcrypt` -_Implementation_: path.Base +## `biggest` -## bcrypt -Receives a string and generates its bcrypt hash. -_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. -_Implementation_: github.com/Masterminds/sprig/v3.max -## buildCustomCert -Allows customizing the certificate. It takes Base64 encoded PEM format certificate and private key as arguments and 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 -_Implementation_: github.com/Masterminds/sprig/v3.buildCustomCertificate -## camelcase +_Example_: `$ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-key"` -_Implementation_: github.com/huandu/xstrings.ToPascalCase -## cat +_Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` +## `camelcase` +Converts a string from snake_case to camelCase. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.cat +- String to convert -## ceil -Returns greatest float value greater than or equal to input value. `ceil 123.001` will return `124.0`. -_Implementation_: github.com/Masterminds/sprig/v3.ceil +_Example_: `camelcase "http_server"` returns `HttpServer`. -## chunk +_Implementation_: `github.com/huandu/xstrings.ToPascalCase` +## `cat` -_Implementation_: github.com/Masterminds/sprig/v3.chunk -## clean -_Implementation_: path.Clean -## coalesce +_Implementation_: `github.com/Masterminds/sprig/v3.cat` +## `ceil` +Returns greatest float value greater than or equal to input value. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.coalesce +- Input value -## compact + + + +_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 + + + + +_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_: -_Implementation_: github.com/Masterminds/sprig/v3.concat +- Substring -## contains -Tests if one string is contained inside of another. `contains "cat" "catch"` will return `true`. +- String -_Implementation_: github.com/Masterminds/sprig/v3.init.func9 -## date -Formats date. +_Example_: `contains "cat" "catch"` returns `true`. -_Implementation_: github.com/Masterminds/sprig/v3.date +_Implementation_: `github.com/Masterminds/sprig/v3.init.func9` -## dateInZone +## `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 -_Implementation_: github.com/Masterminds/sprig/v3.dateInZone +- Timezone -## dateModify +_Example_: `dateInZone "2006-01-02" (now) "UTC"`. -_Implementation_: github.com/Masterminds/sprig/v3.dateModify -## date_in_zone +_Aliases_: `date_in_zone`\ +_Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` +## `dateModify` +Allows date modifications. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.dateInZone +- Date modification -## date_modify +- Date -_Implementation_: github.com/Masterminds/sprig/v3.dateModify +_Example_: `now | dateModify "-1.5h"` will subtract an hour and thirty minutes from the current time. -## decryptAES + +_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 +_Implementation_: `github.com/Masterminds/sprig/v3.decryptAES` -_Implementation_: github.com/Masterminds/sprig/v3.deepCopy +## `deepCopy` +Makes deep copy of the value. This includes maps and other structures. It will panic if there is a problem. -## deepEqual +_Parameters_: +- Value to copy -_Implementation_: reflect.DeepEqual -## default +_Example_: `dict "a" 1 "b" 2 | deepCopy`. -_Implementation_: github.com/pluralsh/polly/template.dfault +_Implementation_: `github.com/Masterminds/sprig/v3.deepCopy` -## derivePassword +## `deepEqual` -_Implementation_: github.com/Masterminds/sprig/v3.derivePassword -## dict +_Implementation_: `reflect.DeepEqual` +## `default` -_Implementation_: github.com/Masterminds/sprig/v3.dict -## dig -_Implementation_: github.com/Masterminds/sprig/v3.dig -## dir +_Implementation_: `github.com/pluralsh/polly/template.dfault` +## `derivePassword` -_Implementation_: path.Dir -## div + + + +_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 +_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`. -_Implementation_: github.com/Masterminds/sprig/v3.duration -## durationRound +_Implementation_: `github.com/Masterminds/sprig/v3.init.func24` +## `duration` +Formats a given amount of seconds as a `time.Duration`. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.durationRound +- Amount of seconds -## empty +_Example_: `duration "95"` returns `1m35s`. -_Implementation_: github.com/Masterminds/sprig/v3.empty -## encryptAES -Encrypts text with AES-256 CBC and returns a Base64 encoded string. +_Implementation_: `github.com/Masterminds/sprig/v3.duration` +## `durationRound` -_Implementation_: github.com/Masterminds/sprig/v3.encryptAES -## env -Reads environment variable. -_Implementation_: os.Getenv -## expandenv -Substitutes environment variable in a string. +_Implementation_: `github.com/Masterminds/sprig/v3.durationRound` +## `empty` +Returns true if given value has the zero value for its type. -_Implementation_: os.ExpandEnv -## ext -Returns file extension. `ext "foo.bar"` will return `"bar"`. +_Parameters_: +- Value -_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. +_Example_: `empty .Foo`. -_Implementation_: github.com/Masterminds/sprig/v3.init.func26 -## first -Returns head item on a list. +_Implementation_: `github.com/Masterminds/sprig/v3.empty` +## `encryptAES` +Encrypts text with AES-256 CBC and returns a Base64 encoded string. -_Implementation_: github.com/Masterminds/sprig/v3.first +_Parameters_: -## float64 -Converts to a `float64`. +- Secret key +- Text to encrypt -_Implementation_: github.com/Masterminds/sprig/v3.toFloat64 -## floor -Returns the greatest float value greater than or equal to input value. `floor 123.9999` will return `123.0`. +_Example_: `encryptAES "secretkey" "plaintext"`. -_Implementation_: github.com/Masterminds/sprig/v3.floor -## fromJson +_Implementation_: `github.com/Masterminds/sprig/v3.encryptAES` +## `env` +Reads environment variable. -_Aliases_: from_json -_Implementation_: github.com/Masterminds/sprig/v3.fromJson +_Parameters_: -## genCA -Generates a new, self-signed x509 SSL Certificate Authority using 2048-bit RSA private key. It takes subject common name (CN) and cert validity duration in days as parameters. 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. +- Environment variable name -_Implementation_: github.com/Masterminds/sprig/v3.generateCertificateAuthority -## genCAWithKey -Generates a new, self-signed x509 SSL Certificate Authority using given private key. It takes subject common name (CN), cert validity duration in days and private key (PEM-encoded; DSA keys are not supported) as parameters. 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. +_Example_: `env "HOME"` -_Implementation_: github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey +_Implementation_: `os.Getenv` -## genPrivateKey +## `expandenv` +Substitutes environment variable in a string. +_Parameters_: +- String to expand -_Implementation_: github.com/Masterminds/sprig/v3.generatePrivateKey -## genSelfSignedCert -Generates an SSL self-signed certificate. +_Example_: `expandenv "Your path is set to $PATH"` -_Implementation_: github.com/Masterminds/sprig/v3.generateSelfSignedCertificate -## genSelfSignedCertWithKey +_Implementation_: `os.ExpandEnv` +## `ext` +Returns file extension. -_Implementation_: github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey +_Parameters_: -## genSignedCert -Generates an SSL certificate and key based on a given CA. +- File path -_Implementation_: github.com/Masterminds/sprig/v3.generateSignedCertificate -## genSignedCertWithKey +_Example_: `ext "foo.bar"` will return `"bar"` +_Implementation_: `path.Ext` -_Implementation_: github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey +## `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. -## get +_Parameters_: +- Error message -_Implementation_: github.com/Masterminds/sprig/v3.get -## getHostByName +_Example_: `fail "Please accept the end user license agreement"` -_Implementation_: github.com/Masterminds/sprig/v3.getHostByName +_Implementation_: `github.com/Masterminds/sprig/v3.init.func26` -## has -Checks if a list has a particular element. +## `first` +Returns head item on a list. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.has +- List -## hasKey -_Implementation_: github.com/Masterminds/sprig/v3.hasKey -## hasPrefix +_Implementation_: `github.com/Masterminds/sprig/v3.first` +## `float64` +Converts to a `float64` +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.init.func10 +- Value to convert, it can be for example an integer or a string -## hasSuffix -_Implementation_: github.com/Masterminds/sprig/v3.init.func11 -## htmlDate -Formats a date for inserting into HTML date picker input field. +_Implementation_: `github.com/Masterminds/sprig/v3.toFloat64` +## `floor` +Returns the greatest float value greater than or equal to input value. -_Implementation_: github.com/Masterminds/sprig/v3.htmlDate +_Parameters_: -## htmlDateInZone -Same as `htmlDate` but with a timezone. +- Input value -_Implementation_: github.com/Masterminds/sprig/v3.htmlDateInZone -## htpasswd +_Example_: `floor 123.9999` will return `123.0` +_Implementation_: `github.com/Masterminds/sprig/v3.floor` -_Implementation_: github.com/Masterminds/sprig/v3.htpasswd +## `fromJson` +Decodes a JSON document into a structure. If the input cannot be decoded as JSON the function will return an empty string. -## indent +_Parameters_: +- JSON document -_Implementation_: github.com/pluralsh/polly/template.indent -## initial -Compliments `last` by retuning all but the last element. +_Example_: `fromJson "{\"foo\": 55}"`. -_Implementation_: github.com/Masterminds/sprig/v3.initial +_Aliases_: `from_json`\ +_Implementation_: `github.com/Masterminds/sprig/v3.fromJson` -## initials +## `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) -_Implementation_: github.com/Masterminds/sprig/v3.initials +- Cert validity duration in days -## int -Converts to a `int`. -_Implementation_: github.com/Masterminds/sprig/v3.toInt -## int64 -Converts to a `int64`. +_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. -_Implementation_: github.com/Masterminds/sprig/v3.toInt64 -## isAbs -Checks whether a path is absolute. +_Parameters_: + +- Subject common name (CN) +- Cert validity duration in days +- private key (PEM-encoded; DSA keys are not supported) -_Implementation_: path.IsAbs -## join -_Implementation_: github.com/Masterminds/sprig/v3.join +_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey` -## kebabcase +## `genPrivateKey` +Generates a new private key encoded into a PEM block. +_Parameters_: +- Key type (ecdsa, dsa, rsa or ed25519) -_Implementation_: github.com/huandu/xstrings.ToKebabCase -## keys -_Implementation_: github.com/Masterminds/sprig/v3.keys +_Implementation_: `github.com/Masterminds/sprig/v3.generatePrivateKey` -## kindIs +## `genSelfSignedCert` +Generates an SSL self-signed certificate. -_Implementation_: github.com/Masterminds/sprig/v3.kindIs -## kindOf +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificate` +## `genSelfSignedCertWithKey` -_Implementation_: github.com/Masterminds/sprig/v3.kindOf -## last -_Implementation_: github.com/Masterminds/sprig/v3.last +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey` -## list +## `genSignedCert` +Generates an SSL certificate and key based on a given CA. -_Implementation_: github.com/Masterminds/sprig/v3.list -## lower -Converts the entire string to lowercase. `upper "HELLO"` will return `hello`. +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificate` +## `genSignedCertWithKey` -_Implementation_: strings.ToLower -## max -Returns the largest of a series of integers. `max 1 2 3` will return `3`. -_Implementation_: github.com/Masterminds/sprig/v3.max -## maxf +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey` +## `get` -_Implementation_: github.com/Masterminds/sprig/v3.maxf -## merge -_Implementation_: github.com/Masterminds/sprig/v3.merge +_Implementation_: `github.com/Masterminds/sprig/v3.get` -## mergeOverwrite +## `getHostByName` -_Implementation_: github.com/Masterminds/sprig/v3.mergeOverwrite -## min -Returns the smallest of a series of integers. `min 1 2 3` will return `1`. +_Implementation_: `github.com/Masterminds/sprig/v3.getHostByName` -_Implementation_: github.com/Masterminds/sprig/v3.min +## `has` +Checks if a list has a particular element. It will panic if there is a problem. -## minf +_Parameters_: +- Element to find +- List -_Implementation_: github.com/Masterminds/sprig/v3.minf -## mod +_Example_: `has 4 $myList` -_Implementation_: github.com/Masterminds/sprig/v3.init.func18 -## mul -Multiples numbers. Accepts two or more inputs. `mul 1 2 3` will return `6`. +_Implementation_: `github.com/Masterminds/sprig/v3.has` +## `hasKey` +Checks if given dictionary contains given key. -_Implementation_: github.com/Masterminds/sprig/v3.init.func19 +_Parameters_: -## mulf +- Map +- Key to find -_Implementation_: github.com/Masterminds/sprig/v3.init.func25 -## mustAppend -Appends a new item to existing list, creating a new list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +_Implementation_: `github.com/Masterminds/sprig/v3.hasKey` -_Implementation_: github.com/Masterminds/sprig/v3.mustPush +## `hasPrefix` +Check if string has given prefix. -## mustChunk +_Parameters_: +- Prefix +- String -_Implementation_: github.com/Masterminds/sprig/v3.mustChunk -## mustCompact -Accepts a list and removes entries with empty values. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. -_Implementation_: github.com/Masterminds/sprig/v3.mustCompact -## mustDateModify +_Implementation_: `github.com/Masterminds/sprig/v3.init.func10` +## `hasSuffix` +Check if string has given suffix. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.mustDateModify +- Prefix -## mustDeepCopy +- Suffix -_Implementation_: github.com/Masterminds/sprig/v3.mustDeepCopy -## mustFirst -Returns head item on a list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func11` +## `htmlDate` +Formats a date for inserting into HTML date picker input field. -_Implementation_: github.com/Masterminds/sprig/v3.mustFirst -## mustFromJson +_Parameters_: +- Date -_Implementation_: github.com/Masterminds/sprig/v3.mustFromJson -## mustHas -Checks if a list has a particular element. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +_Example_: `now | htmlDate`. -_Implementation_: github.com/Masterminds/sprig/v3.mustHas +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDate` -## mustInitial -Compliments `last` by retuning all but the last element. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +## `htmlDateInZone` +Same as `htmlDate` but with a timezone. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.mustInitial +- Date -## mustLast +- Timezone -_Implementation_: github.com/Masterminds/sprig/v3.mustLast +_Example_: `htmlDateInZone (now) "UTC"`. -## mustMerge +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDateInZone` +## `htpasswd` -_Implementation_: github.com/Masterminds/sprig/v3.mustMerge -## mustMergeOverwrite -_Implementation_: github.com/Masterminds/sprig/v3.mustMergeOverwrite -## mustPrepend +_Implementation_: `github.com/Masterminds/sprig/v3.htpasswd` +## `indent` -_Implementation_: github.com/Masterminds/sprig/v3.mustPrepend -## mustPush +_Implementation_: `github.com/pluralsh/polly/template.indent` -_Implementation_: github.com/Masterminds/sprig/v3.mustPush +## `initial` +Compliments `last` by retuning all but the last element. It will panic if there is a problem. -## mustRegexFind +_Parameters_: +- List -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexFind -## mustRegexFindAll +_Implementation_: `github.com/Masterminds/sprig/v3.initial` -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexFindAll +## `initials` -## mustRegexMatch -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexMatch -## mustRegexReplaceAll +_Implementation_: `github.com/Masterminds/sprig/v3.initials` +## `int` +Converts to a `int`. -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexReplaceAll +_Parameters_: -## mustRegexReplaceAllLiteral +- Value to convert -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral -## mustRegexSplit +_Implementation_: `github.com/Masterminds/sprig/v3.toInt` +## `int64` +Converts to a `int64`. -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexSplit +_Parameters_: -## mustRest -Gets tail of the list (everything but the first item). Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +- Value to convert -_Implementation_: github.com/Masterminds/sprig/v3.mustRest -## mustReverse -Produces a new list with the reversed elements of the given list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +_Implementation_: `github.com/Masterminds/sprig/v3.toInt64` -_Implementation_: github.com/Masterminds/sprig/v3.mustReverse +## `isAbs` +Checks whether a path is absolute. -## mustSlice +_Parameters_: +- File path -_Implementation_: github.com/Masterminds/sprig/v3.mustSlice -## mustToDate -Converts a string to a date. The first argument is the date layout and the second is the date string. If the string can’t be converted it returns the zero value. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. -_Implementation_: github.com/Masterminds/sprig/v3.mustToDate +_Implementation_: `path.IsAbs` -## mustToJson +## `join` -_Implementation_: github.com/Masterminds/sprig/v3.mustToJson -## mustToPrettyJson +_Implementation_: `github.com/Masterminds/sprig/v3.join` +## `kebabcase` +Converts a string from camelCase to kebab-case. -_Implementation_: github.com/Masterminds/sprig/v3.mustToPrettyJson -## mustToRawJson +_Parameters_: +- String to convert -_Implementation_: github.com/Masterminds/sprig/v3.mustToRawJson -## mustUniq -Generates a list with all of the duplicates removed. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +_Example_: `kebabcase "FirstName"` returns `first-name`. -_Implementation_: github.com/Masterminds/sprig/v3.mustUniq +_Implementation_: `github.com/huandu/xstrings.ToKebabCase` -## mustWithout -Filters items out of a list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine. +## `keys` +Returns list of all keys from a map. +_Parameters_: -_Implementation_: github.com/Masterminds/sprig/v3.mustWithout +- Map -## must_date_modify -_Implementation_: github.com/Masterminds/sprig/v3.mustDateModify -## nindent +_Implementation_: `github.com/Masterminds/sprig/v3.keys` +## `kindIs` -_Implementation_: github.com/pluralsh/polly/template.nindent -## nospace -Removes all whitespace from a string. `nospace "hello w o r l d"` will return `helloworld`. -_Implementation_: github.com/Masterminds/goutils.DeleteWhiteSpace +_Implementation_: `github.com/Masterminds/sprig/v3.kindIs` -## omit +## `kindOf` -_Implementation_: github.com/Masterminds/sprig/v3.omit -## osBase -Returns the last element of a file path. `osBase "/foo/bar/baz"` and `osBase "C:\\foo\\bar\\baz"` will return `"baz"` on Linux and Windows, respectively. +_Implementation_: `github.com/Masterminds/sprig/v3.kindOf` -_Implementation_: path/filepath.Base +## `last` -## osClean -Cleans up a path. `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. So `osDir "/foo/bar/baz"` returns `/foo/bar` on Linux, and `osDir "C:\\foo\\bar\\baz"` returns `C:\\foo\\bar` on Windows. +_Implementation_: `github.com/Masterminds/sprig/v3.last` -_Implementation_: path/filepath.Dir +## `list` -## osExt -Return the file extension. `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. +_Implementation_: `github.com/Masterminds/sprig/v3.list` -_Implementation_: path/filepath.IsAbs +## `lower` +Converts the entire string to lowercase. -## pick +_Parameters_: +- String to transform -_Implementation_: github.com/Masterminds/sprig/v3.pick -## pluck +_Example_: `upper \"HELLO\"` will return `hello`. -_Implementation_: github.com/Masterminds/sprig/v3.pluck +_Implementation_: `strings.ToLower` -## plural +## `max` +Returns the largest of a series of integers. +_Parameters_: +- Number -_Implementation_: github.com/Masterminds/sprig/v3.plural +- Number -## prepend +- ... -_Implementation_: github.com/Masterminds/sprig/v3.prepend +_Example_: `max 1 2 3` will return `3`. -## push +_Implementation_: `github.com/Masterminds/sprig/v3.max` +## `maxf` +Returns the largest of a series of floats. -_Implementation_: github.com/Masterminds/sprig/v3.push -## quote +_Parameters_: +- Float number +- Float number +- ... -_Implementation_: github.com/Masterminds/sprig/v3.quote -## randAlpha +_Example_: `max 1 2 3.65` will return `3.65`. -_Implementation_: github.com/Masterminds/sprig/v3.randAlpha -## randAlphaNum +_Implementation_: `github.com/Masterminds/sprig/v3.maxf` +## `merge` -_Implementation_: github.com/Masterminds/sprig/v3.randAlphaNumeric -## randAscii +_Implementation_: `github.com/Masterminds/sprig/v3.merge` -_Implementation_: github.com/Masterminds/sprig/v3.randAscii +## `mergeOverwrite` -## randBytes -Accepts a count `N` and generates cryptographically secure random sequence of `N` bytes. The sequence is returned as a Base64 encoded string. -_Implementation_: github.com/Masterminds/sprig/v3.randBytes -## randInt -Returns a random integer value from min (inclusive) to max (exclusive). `randInt 12 30` will produce a random number in the range from 12 to 30. +_Implementation_: `github.com/Masterminds/sprig/v3.mergeOverwrite` -_Implementation_: github.com/Masterminds/sprig/v3.init.func20 +## `min` +Returns the smallest of a series of integers. -## randNumeric +_Parameters_: +- Number +- Number -_Implementation_: github.com/Masterminds/sprig/v3.randNumeric +- ... -## regexFind +_Example_: `min 1 2 3` will return `1`. -_Implementation_: github.com/Masterminds/sprig/v3.regexFind -## regexFindAll +_Implementation_: `github.com/Masterminds/sprig/v3.min` +## `minf` +Returns the smallest of a series of floats. -_Implementation_: github.com/Masterminds/sprig/v3.regexFindAll +_Parameters_: -## regexMatch +- Float number +- Float number +- ... -_Implementation_: github.com/Masterminds/sprig/v3.regexMatch -## regexQuoteMeta +_Example_: `min 1.3 2 3` will return `1.3`. -_Implementation_: github.com/Masterminds/sprig/v3.regexQuoteMeta +_Implementation_: `github.com/Masterminds/sprig/v3.minf` -## regexReplaceAll +## `mod` -_Implementation_: github.com/Masterminds/sprig/v3.regexReplaceAll -## regexReplaceAllLiteral +_Implementation_: `github.com/Masterminds/sprig/v3.init.func18` +## `mul` +Multiplies numbers. Accepts two or more inputs. -_Implementation_: github.com/Masterminds/sprig/v3.regexReplaceAllLiteral -## regexSplit +_Parameters_: +- Number +- Number +- ... -_Implementation_: github.com/Masterminds/sprig/v3.regexSplit -## repeat +_Example_: `mul 1 2 3` will return `6`. -_Implementation_: github.com/Masterminds/sprig/v3.init.func2 -## replace +_Implementation_: `github.com/Masterminds/sprig/v3.init.func19` +## `mulf` +Multiplies float numbers. Accepts two or more inputs. +_Parameters_: -_Implementation_: strings.ReplaceAll +- Float number -## rest -Gets tail of the list (everything but the first item). +- Float number +- ... -_Implementation_: github.com/Masterminds/sprig/v3.rest -## reverse -Produces a new list with the reversed elements of the given list. +_Example_: `mulf 1.5 2 2` returns `6`. -_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. `round 123.55555 3` will return `123.556`. +_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. -_Implementation_: github.com/Masterminds/sprig/v3.round +_Parameters_: -## semver +- List +- Item to append -_Implementation_: github.com/Masterminds/sprig/v3.semver -## semverCompare +_Example_: `mustAppend ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`. -_Aliases_: semver_compare -_Implementation_: github.com/Masterminds/sprig/v3.semverCompare +_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` -## 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`. +## `mustChunk` -_Implementation_: github.com/Masterminds/sprig/v3.seq -## set +_Implementation_: `github.com/Masterminds/sprig/v3.mustChunk` -_Implementation_: github.com/Masterminds/sprig/v3.set +## `mustCompact` +Accepts a list and removes entries with empty values. It will return an error to the template engine if there is a problem. -## sha1sum +_Parameters_: +- List -_Implementation_: github.com/Masterminds/sprig/v3.sha1sum -## sha256sum -_Aliases_: sha26sum -_Implementation_: github.com/Masterminds/sprig/v3.sha256sum +_Implementation_: `github.com/Masterminds/sprig/v3.mustCompact` -## sha512sum +## `mustDateModify` -_Implementation_: github.com/Masterminds/sprig/v3.sha512sum -## shuffle +_Aliases_: `must_date_modify`\ +_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` +## `mustDeepCopy` -_Implementation_: github.com/huandu/xstrings.Shuffle -## slice -_Implementation_: github.com/Masterminds/sprig/v3.slice +_Implementation_: `github.com/Masterminds/sprig/v3.mustDeepCopy` -## snakecase +## `mustFirst` +Returns head item on a list. It will return an error to the template engine if there is a problem. +_Parameters_: +- List -_Implementation_: github.com/huandu/xstrings.ToSnakeCase -## sortAlpha +_Example_: `mustFirst $myList` -_Implementation_: github.com/Masterminds/sprig/v3.sortAlpha -## split +_Implementation_: `github.com/Masterminds/sprig/v3.mustFirst` +## `mustFromJson` -_Implementation_: github.com/Masterminds/sprig/v3.split -## splitList +_Implementation_: `github.com/Masterminds/sprig/v3.mustFromJson` -_Implementation_: github.com/Masterminds/sprig/v3.init.func13 +## `mustHas` +Checks if a list has a particular element. It will return an error to the template engine if there is a problem. -## splitn +_Parameters_: +- Element to find +- List -_Implementation_: github.com/Masterminds/sprig/v3.splitn -## squote +_Example_: `mustHas 4 $myList` -_Implementation_: github.com/Masterminds/sprig/v3.squote -## sub +_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_: -_Implementation_: github.com/Masterminds/sprig/v3.init.func16 +- List -## subf +_Example_: `mustInitial $myList` -_Implementation_: github.com/Masterminds/sprig/v3.init.func23 -## substr +_Implementation_: `github.com/Masterminds/sprig/v3.mustInitial` +## `mustLast` -_Implementation_: github.com/Masterminds/sprig/v3.substring -## swapcase -_Implementation_: github.com/Masterminds/goutils.SwapCase +_Implementation_: `github.com/Masterminds/sprig/v3.mustLast` -## 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. `ternary "foo" "bar" true` or `true | "foo" "bar"` will return `"foo"`. +## `mustMerge` -_Implementation_: github.com/pluralsh/polly/template.ternary -## title -Converts a string to title case. `title "hello world"` will return `"Hello World"`. -_Implementation_: strings.Title +_Implementation_: `github.com/Masterminds/sprig/v3.mustMerge` -## toDate -Converts a string to a date. The first argument is the date layout and the second is the date string. If the string can’t be converted it returns the zero value. +## `mustMergeOverwrite` -_Implementation_: github.com/Masterminds/sprig/v3.toDate -## toDecimal -Converts a Unix octal to a `int64`.`"0777" | toDecimal` will convert `0777` to `511` and return the value as `int64`. -_Implementation_: github.com/Masterminds/sprig/v3.toDecimal +_Implementation_: `github.com/Masterminds/sprig/v3.mustMergeOverwrite` -## toJson +## `mustPrepend` -_Aliases_: to_json -_Implementation_: github.com/Masterminds/sprig/v3.toJson -## toPrettyJson +_Implementation_: `github.com/Masterminds/sprig/v3.mustPrepend` -_Implementation_: github.com/Masterminds/sprig/v3.toPrettyJson +## `mustPush` -## toRawJson -Encodes an item into JSON string with HTML characters unescaped. `toRawJson .Item` will return unescaped JSON string representation of `.Item`. -_Implementation_: github.com/Masterminds/sprig/v3.toRawJson -## toString -Converts to a string. +_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` -_Implementation_: github.com/Masterminds/sprig/v3.strval +## `mustRegexFind` -## toStrings -Converts a list, slice or array to a list of strings. `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. `trim " hello "` will return `hello`. +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFind` -_Implementation_: strings.TrimSpace +## `mustRegexFindAll` -## trimAll -Removes given characters from the front or back of a string. `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. `trimPrefix "-" "-hello"` will return `hello`. +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFindAll` -_Implementation_: github.com/Masterminds/sprig/v3.init.func6 +## `mustRegexMatch` -## trimSuffix -Trims just the suffix from a string. `trimSuffix "-" "hello-"` will return `hello`. -_Implementation_: github.com/Masterminds/sprig/v3.init.func5 -## trimall +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexMatch` +## `mustRegexReplaceAll` -_Implementation_: github.com/Masterminds/sprig/v3.init.func3 -## trunc -_Implementation_: github.com/Masterminds/sprig/v3.trunc -## tuple +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAll` +## `mustRegexReplaceAllLiteral` -_Implementation_: github.com/Masterminds/sprig/v3.list -## typeIs +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral` -_Implementation_: github.com/Masterminds/sprig/v3.typeIs +## `mustRegexSplit` -## typeIsLike -_Implementation_: github.com/Masterminds/sprig/v3.typeIsLike -## typeOf +_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. -_Implementation_: github.com/Masterminds/sprig/v3.typeOf +_Parameters_: -## uniq -Generates a list with all of the duplicates removed. +- List -_Implementation_: github.com/Masterminds/sprig/v3.uniq -## unixEpoch -Returns the seconds since the Unix epoch. +_Example_: `mustRest $myList` -_Implementation_: github.com/Masterminds/sprig/v3.unixEpoch +_Implementation_: `github.com/Masterminds/sprig/v3.mustRest` -## 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. +## `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_: -_Implementation_: github.com/Masterminds/sprig/v3.unset +- List -## until -Builds a range of integers. `until 5` will return a list `[0, 1, 2, 3, 4]`. -_Implementation_: github.com/Masterminds/sprig/v3.until +_Example_: `mustReverse $myList` -## untilStep -Like `until` generates a list of counting integers but it allows to define a start, stop and step. `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.mustReverse` -_Implementation_: github.com/Masterminds/sprig/v3.untilStep +## `mustSlice` -## untitle -Removes title casing. `untitle "Hello World"` will return `"hello world"`. -_Implementation_: github.com/Masterminds/sprig/v3.untitle -## upper -Converts the entire string to uppercase. `upper "hello"` will return `HELLO`. +_Implementation_: `github.com/Masterminds/sprig/v3.mustSlice` -_Implementation_: strings.ToUpper +## `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. -## urlJoin -Joins map produced by `urlParse` to produce URL string. `urlJoin (dict "fragment" "fragment" "host" "host:80" "path" "/path" "query" "query" "scheme" "http")` will return `proto://host:80/path?query#fragment`. +_Parameters_: +- Date layout -_Implementation_: github.com/Masterminds/sprig/v3.urlJoin +- Date string -## urlParse -Parses string for URL and produces dict with URL parts. For more info check https://golang.org/pkg/net/url/#URL. -_Implementation_: github.com/Masterminds/sprig/v3.urlParse -## values +_Implementation_: `github.com/Masterminds/sprig/v3.mustToDate` +## `mustToJson` -_Implementation_: github.com/Masterminds/sprig/v3.values -## without -Filters items out of a list. It can take more than one filter. -_Implementation_: github.com/Masterminds/sprig/v3.without -## wrap -Wraps text at a given column count. `wrap 80 $text` will wrap the string in `$text` at 80 columns. +_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 -_Implementation_: github.com/Masterminds/sprig/v3.init.func7 -## wrapWith -Works as `wrap` but lets you specify the string to wrap with (`wrap` uses `\n`). `wrapWith 5 "\t" "Hello world"` will return `hello world` (where the whitespace is an ASCII tab character). +_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 +_Implementation_: `github.com/Masterminds/sprig/v3.init.func8` diff --git a/docs/liquid-filters.tmpl b/docs/liquid-filters.tmpl new file mode 100644 index 0000000..8bbff9c --- /dev/null +++ b/docs/liquid-filters.tmpl @@ -0,0 +1,19 @@ +# Supported Liquid Filters +{{ range . }} +## `{{ .Name }}` +{{ .Documentation.Description }} + +{{ if .Documentation.Parameters }} +_Parameters_: +{{ range .Documentation.Parameters }} +- {{ . }} +{{ end }} +{{ end }} + +{{ if .Documentation.Example }} +_Example_: {{ .Documentation.Example }} +{{ end }} + +{{ if .Aliases }}_Aliases_: {{ range $index, $element := .Aliases}}{{ if $index}}, {{end}}`{{$element}}`{{ end }}\{{ end }} +_Implementation_: `{{ .Implementation }}` +{{ end }} \ No newline at end of file diff --git a/internal/template/docs.go b/internal/template/docs.go index f91a34b..262330c 100644 --- a/internal/template/docs.go +++ b/internal/template/docs.go @@ -3,6 +3,7 @@ package main import ( "io" "os" + "path" "sort" "strings" "text/template" @@ -14,15 +15,7 @@ import ( const ( docsPath = "docs/liquid-filters.md" - docsTemplate = `# Supported Liquid Filters -{{ range . }} -## {{ .Name }} -{{ .Description }} - -{{ if .Aliases }}_Aliases_: {{ .Aliases | join ", " }}{{ end }} - -_Implementation_: {{ .Implementation }} -{{ end }}` + docsTemplate = "docs/liquid-filters.tmpl" ) func main() { @@ -31,7 +24,7 @@ func main() { panic(err) } - if err = generateFilterDocs(f, registeredFilters()); err != nil { + if err = generateFilterDocs(f, registeredFilters(), docsTemplate); err != nil { panic(err) } } @@ -45,7 +38,7 @@ func registeredFilters() []tmpl.FilterFunction { return filters } -func generateFilterDocs(writer io.Writer, filters []tmpl.FilterFunction) error { - t := template.Must(template.New("").Funcs(sprig.TxtFuncMap()).Parse(docsTemplate)) +func generateFilterDocs(writer io.Writer, filters []tmpl.FilterFunction, templatePath string) error { + t := template.Must(template.New(path.Base(templatePath)).Funcs(sprig.TxtFuncMap()).ParseFiles(templatePath)) return t.Execute(writer, filters) } diff --git a/internal/template/docs_test.go b/internal/template/docs_test.go index ea96cd9..a6792f8 100644 --- a/internal/template/docs_test.go +++ b/internal/template/docs_test.go @@ -10,7 +10,7 @@ import ( func TestLiquidFunctionDocs(t *testing.T) { b := new(bytes.Buffer) - err := generateFilterDocs(b, registeredFilters()) + err := generateFilterDocs(b, registeredFilters(), "../../docs/liquid-filters.tmpl") assert.NoError(t, err) f, err := os.ReadFile("../../docs/liquid-filters.md") diff --git a/template/liquid.go b/template/liquid.go index 64bf2bc..0828236 100644 --- a/template/liquid.go +++ b/template/liquid.go @@ -11,24 +11,40 @@ import ( ) type FilterFunction struct { - Name string `json:"name"` - Aliases []string `json:"aliases,omitempty"` - Description string `json:"description,omitempty"` - Implementation string `json:"implementation,omitempty"` + Name string `json:"name"` + Aliases []string `json:"aliases,omitempty"` + Documentation FilterFunctionDocumentation `json:"description,omitempty"` + Implementation string `json:"implementation,omitempty"` +} + +type FilterFunctionDocumentation struct { + Description string `json:"description,omitempty"` + Parameters []string `json:"parameters,omitempty"` + Example string `json:"example,omitempty"` } var ( liquidEngine = liquid.NewEngine() // excludedSprigFunctions contains names of Spring functions that will be excluded. - excludedSprigFunctions = []string{"hello", "now", "uuidv4"} + excludedSprigFunctions = []string{ + "date_in_zone", + "date_modify", + "hello", + "must_date_modify", + "now", + "uuidv4", + } // sprigFunctionNameAliases contains additional aliases for Sprig functions. sprigFunctionNameAliases = map[string][]string{ - "toJson": {"to_json"}, - "fromJson": {"from_json"}, - "semverCompare": {"semver_compare"}, - "sha256sum": {"sha26sum"}, + "dateInZone": {"date_in_zone"}, + "dateModify": {"date_modify"}, + "mustDateModify": {"must_date_modify"}, + "toJson": {"to_json"}, + "fromJson": {"from_json"}, + "semverCompare": {"semver_compare"}, + "sha256sum": {"sha26sum"}, } // internalFunctions to register. These will override Sprig functions if same names are used. @@ -68,7 +84,7 @@ func registerFilter(name string, aliases []string, fn any) { registeredFunctions[name] = FilterFunction{ Name: name, Aliases: aliases, - Description: functionDocs[name], + Documentation: functionDocs[name], Implementation: runtime.FuncForPC(reflect.ValueOf(fn).Pointer()).Name(), } } diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 6760ddf..91d4b20 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -1,212 +1,636 @@ package template -var functionDocs = map[string]string{ - "abbrev": "", - "abbrevboth": "", - "add": "Sums numbers. Accepts two or more inputs. `add 1 2 3` will return `6`.", - "add1": "Increments by 1. `add1 3` will return `4`.", - "add1f": "Increments float number by 1.", - "addf": "Sums float numbers.", - "adler32sum": "Receives a string and computes its Adler-32 checksum.", - "ago": "Returns duration from current time in seconds resolution.", - "all": "Takes a list of values ad returns true if all values are non-empty.", - "any": "Takes a list of values ad returns true if any values are non-empty.", - "append": "Appends a new item to existing list, creating a new list.", - "atoi": "Converts a string to an integer.", - "b32dec": "Decodes string from Base32 format.", - "b32enc": "Encodes string with Base32 format.", - "b64dec": "Decodes string from Base64 format.", - "b64enc": "Encodes string with Base64 format.", - "base": "", - "bcrypt": "Receives a string and generates its bcrypt hash.", - "biggest": "", - "buildCustomCert": "Allows customizing the certificate. It takes Base64 encoded PEM format certificate and private key as arguments and 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.", - "camelcase": "", - "cat": "", - "ceil": "Returns greatest float value greater than or equal to input value. `ceil 123.001` will return `124.0`.", - "chunk": "", - "clean": "", - "coalesce": "", - "compact": "Accepts a list and removes entries with empty values.", - "concat": "Concatenates arbitrary number of lists into one.", - "contains": "Tests if one string is contained inside of another. `contains \"cat\" \"catch\"` will return `true`.", - "date": "Formats date.", - "dateInZone": "Same as `date` but with a timezone.", - "dateModify": "", - "date_in_zone": "", - "date_modify": "", - "decryptAES": "Receives a Base64 string encoded by the AES-256 CBC algorithm and returns the decoded text.", - "deepCopy": "", - "deepEqual": "", - "default": "", - "derivePassword": "", - "dict": "", - "dig": "", - "dir": "", - "div": "Performs integer division.", - "divf": "", - "duration": "Formats a given amount of seconds as a `time.Duration`.", - "durationRound": "", - "empty": "", - "encryptAES": "Encrypts text with AES-256 CBC and returns a Base64 encoded string.", - "env": "Reads environment variable.", - "expandenv": "Substitutes environment variable in a string.", - "ext": "Returns file extension. `ext \"foo.bar\"` will return `\"bar\"`.", - "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.", - "first": "Returns head item on a list.", - "float64": "Converts to a `float64`.", - "floor": "Returns the greatest float value greater than or equal to input value. `floor 123.9999` will return `123.0`.", - "fromJson": "", - "genCA": "Generates a new, self-signed x509 SSL Certificate Authority using 2048-bit RSA private key. It takes subject common name (CN) and cert validity duration in days as parameters. 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.", - "genCAWithKey": "Generates a new, self-signed x509 SSL Certificate Authority using given private key. It takes subject common name (CN), cert validity duration in days and private key (PEM-encoded; DSA keys are not supported) as parameters. 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.", - "genPrivateKey": "", - "genSelfSignedCert": "Generates an SSL self-signed certificate.", - "genSelfSignedCertWithKey": "", - "genSignedCert": "Generates an SSL certificate and key based on a given CA.", - "genSignedCertWithKey": "", - "get": "", - "getHostByName": "", - "has": "Checks if a list has a particular element.", - "hasKey": "", - "hasPrefix": "", - "hasSuffix": "", - "htmlDate": "Formats a date for inserting into HTML date picker input field.", - "htmlDateInZone": "Same as `htmlDate` but with a timezone.", - "htpasswd": "", - "indent": "", - "initial": "Compliments `last` by retuning all but the last element.", - "initials": "", - "int": "Converts to a `int`.", - "int64": "Converts to a `int64`.", - "isAbs": "Checks whether a path is absolute.", - "join": "", - "kebabcase": "", - "keys": "", - "kindIs": "", - "kindOf": "", - "last": "", - "list": "", - "lower": "Converts the entire string to lowercase. `upper \"HELLO\"` will return `hello`.", - "max": "Returns the largest of a series of integers. `max 1 2 3` will return `3`.", - "maxf": "", - "merge": "", - "mergeOverwrite": "", - "min": "Returns the smallest of a series of integers. `min 1 2 3` will return `1`.", - "minf": "", - "mod": "", - "mul": "Multiples numbers. Accepts two or more inputs. `mul 1 2 3` will return `6`.", - "mulf": "", - "mustAppend": "Appends a new item to existing list, creating a new list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustChunk": "", - "mustCompact": "Accepts a list and removes entries with empty values. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustDateModify": "", - "mustDeepCopy": "", - "mustFirst": "Returns head item on a list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustFromJson": "", - "mustHas": "Checks if a list has a particular element. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustInitial": "Compliments `last` by retuning all but the last element. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustLast": "", - "mustMerge": "", - "mustMergeOverwrite": "", - "mustPrepend": "", - "mustPush": "", - "mustRegexFind": "", - "mustRegexFindAll": "", - "mustRegexMatch": "", - "mustRegexReplaceAll": "", - "mustRegexReplaceAllLiteral": "", - "mustRegexSplit": "", - "mustRest": "Gets tail of the list (everything but the first item). Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustReverse": "Produces a new list with the reversed elements of the given list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustSlice": "", - "mustToDate": "Converts a string to a date. The first argument is the date layout and the second is the date string. If the string can’t be converted it returns the zero value. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustToJson": "", - "mustToPrettyJson": "", - "mustToRawJson": "", - "mustUniq": "Generates a list with all of the duplicates removed. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "mustWithout": "Filters items out of a list. Like other `must` functions instead of panicking when there is a problem it will return an error to the template engine.", - "must_date_modify": "", - "nindent": "", - "nospace": "Removes all whitespace from a string. `nospace \"hello w o r l d\"` will return `helloworld`.", - "omit": "", - "osBase": "Returns the last element of a file path. `osBase \"/foo/bar/baz\"` and `osBase \"C:\\\\foo\\\\bar\\\\baz\"` will return `\"baz\"` on Linux and Windows, respectively.", - "osClean": "Cleans up a path. `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.", - "osDir": "Returns the directory, stripping the last part of the path. So `osDir \"/foo/bar/baz\"` returns `/foo/bar` on Linux, and `osDir \"C:\\\\foo\\\\bar\\\\baz\"` returns `C:\\\\foo\\\\bar` on Windows.", - "osExt": "Return the file extension. `osExt \"/foo.bar\"` and `osExt \"C:\\\\foo.bar\"` will return `.bar` on Linux and Windows, respectively.", - "osIsAbs": "Checks whether a file path is absolute.", - "pick": "", - "pluck": "", - "plural": "", - "prepend": "", - "push": "", - "quote": "", - "randAlpha": "", - "randAlphaNum": "", - "randAscii": "", - "randBytes": "Accepts a count `N` and generates cryptographically secure random sequence of `N` bytes. The sequence is returned as a Base64 encoded string.", - "randInt": "Returns a random integer value from min (inclusive) to max (exclusive). `randInt 12 30` will produce a random number in the range from 12 to 30.", - "randNumeric": "", - "regexFind": "", - "regexFindAll": "", - "regexMatch": "", - "regexQuoteMeta": "", - "regexReplaceAll": "", - "regexReplaceAllLiteral": "", - "regexSplit": "", - "repeat": "", - "replace": "", - "rest": "Gets tail of the list (everything but the first item).", - "reverse": "Produces a new list with the reversed elements of the given list.", - "round": "Returns a float value with the remainder rounded to the given number to digits after the decimal point. `round 123.55555 3` will return `123.556`.", - "semver": "", - "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`.", - "set": "", - "sha1sum": "", - "sha256sum": "", - "sha512sum": "", - "shuffle": "", - "slice": "", - "snakecase": "", - "sortAlpha": "", - "split": "", - "splitList": "", - "splitn": "", - "squote": "", - "sub": "", - "subf": "", - "substr": "", - "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. `ternary \"foo\" \"bar\" true` or `true | \"foo\" \"bar\"` will return `\"foo\"`.", - "title": "Converts a string to title case. `title \"hello world\"` will return `\"Hello World\"`.", - "toDate": "Converts a string to a date. The first argument is the date layout and the second is the date string. If the string can’t be converted it returns the zero value.", - "toDecimal": "Converts a Unix octal to a `int64`.`\"0777\" | toDecimal` will convert `0777` to `511` and return the value as `int64`.", - "toJson": "", - "toPrettyJson": "", - "toRawJson": "Encodes an item into JSON string with HTML characters unescaped. `toRawJson .Item` will return unescaped JSON string representation of `.Item`.", - "toString": "Converts to a string.", - "toStrings": "Converts a list, slice or array to a list of strings. `list 1 2 3 | toString` converts `1`, `2` and `3` to strings and then returns them as a list.", - "trim": "Removes space from either side of a string. `trim \" hello \"` will return `hello`.", - "trimAll": "Removes given characters from the front or back of a string. `trimAll \"$\" \"$5.00\"` will return `5.00` (as a string).", - "trimPrefix": "Trims just the prefix from a string. `trimPrefix \"-\" \"-hello\"` will return `hello`.", - "trimSuffix": "Trims just the suffix from a string. `trimSuffix \"-\" \"hello-\"` will return `hello`.", - "trimall": "", - "trunc": "", - "tuple": "", - "typeIs": "", - "typeIsLike": "", - "typeOf": "", - "uniq": "Generates a list with all of the duplicates removed.", - "unixEpoch": "Returns the seconds since the Unix epoch.", - "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.", - "until": "Builds a range of integers. `until 5` will return a list `[0, 1, 2, 3, 4]`.", - "untilStep": "Like `until` generates a list of counting integers but it allows to define a start, stop and step. `untilStep 3 6 2` will return `[3, 5]` by starting with 3 and adding 2 until it is equal or greater than 6.", - "untitle": "Removes title casing. `untitle \"Hello World\"` will return `\"hello world\"`.", - "upper": "Converts the entire string to uppercase. `upper \"hello\"` will return `HELLO`.", - "urlJoin": "Joins map produced by `urlParse` to produce URL string. `urlJoin (dict \"fragment\" \"fragment\" \"host\" \"host:80\" \"path\" \"/path\" \"query\" \"query\" \"scheme\" \"http\")` will return `proto://host:80/path?query#fragment`.", - "urlParse": "Parses string for URL and produces dict with URL parts. For more info check https://golang.org/pkg/net/url/#URL.", - "values": "", - "without": "Filters items out of a list. It can take more than one filter.", - "wrap": "Wraps text at a given column count. `wrap 80 $text` will wrap the string in `$text` at 80 columns.", - "wrapWith": "Works as `wrap` but lets you specify the string to wrap with (`wrap` uses `\\n`). `wrapWith 5 \"\\t\" \"Hello world\"` will return `hello world` (where the whitespace is an ASCII tab character).", +var functionDocs = map[string]FilterFunctionDocumentation{ + "abbrev": { + Description: "Truncates a string with ellipses.", + Parameters: []string{"Max length", "String to truncate"}, + Example: "`abbrev 5 \"hello world\"` returns `he...`.", + }, + "abbrevboth": { + Description: "Truncates both sides of a string with ellipses.", + Parameters: []string{"Left offset", "Max length", "String to truncate"}, + Example: "`abbrevboth 5 10 \"1234 5678 9123\"` returns `...5678...`.", + }, + "add": { + Description: "Sums numbers. Accepts two or more inputs.", + Parameters: []string{"Number to add", "Number to add", "..."}, + Example: "`add 1 2 3` returns `6`.", + }, + "add1": { + Description: "Increments by 1.", + Parameters: []string{"Number to increment"}, + Example: "`add1 3` returns `4`.", + }, + "add1f": { + Description: "Increments float number by 1.", + Parameters: []string{"Float number to increment"}, + Example: "`add1 3.0` returns `4.0`.", + }, + "addf": { + Description: "Sums float numbers. Accepts two or more inputs.", + Parameters: []string{"Float number", "Float number", "..."}, + Example: "`add 1.1 2.2 3.3` returns `6.6`.", + }, + "adler32sum": { + Description: "Computes Adler-32 checksum of a string.", + Parameters: []string{"String"}, + Example: "`adler32sum \"Hello world!\"`.", + }, + "ago": { + Description: "Returns duration from current time (`time.Now`) in seconds resolution.", + Parameters: []string{"Date"}, + Example: "`ago .CreatedAt` will return something like `2h34m7s`.", + }, + "all": { + Description: "Takes a list of values ad returns true if all values are non-empty.", + Parameters: []string{"List"}, + }, + "any": { + Description: "Takes a list of values ad returns true if any values are non-empty.", + Parameters: []string{"List"}, + }, + "append": { + Description: "Appends a new item to existing list, creating a new list.", + Parameters: []string{"List", "Item to append"}, + Example: "`append ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`.", + }, + "atoi": { + Description: "Converts a string to an integer.", + Parameters: []string{"String to convert"}, + }, + "b32dec": { + Description: "Decodes string from Base32 format.", + Parameters: []string{"String to decode"}, + }, + "b32enc": { + Description: "Encodes string with Base32 format.", + Parameters: []string{"String to encode"}, + }, + "b64dec": { + Description: "Decodes string from Base64 format.", + Parameters: []string{"String to decode"}, + }, + "b64enc": { + Description: "Encodes string with Base64 format.", + Parameters: []string{"String to encode"}, + }, + "base": { + Description: "Returns the last element of a path.", + Parameters: []string{"Path"}, + Example: "`base \"foo/bar/baz\"` returns `baz`.", + }, + "bcrypt": { + Description: "Generates bcrypt hash of a string.", + Parameters: []string{"String"}, + }, + "biggest": {}, + "buildCustomCert": { + Description: "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: []string{"Base64 encoded PEM format certificate", "Base64 encoded PEM format private key"}, + Example: "`$ca := buildCustomCert \"base64-encoded-ca-crt\" \"base64-encoded-ca-key\"`", + }, + "camelcase": { + Description: "Converts a string from snake_case to camelCase.", + Parameters: []string{"String to convert"}, + Example: "`camelcase \"http_server\"` returns `HttpServer`.", + }, + "cat": {}, + "ceil": { + Description: "Returns greatest float value greater than or equal to input value.", + Parameters: []string{"Input value"}, + Example: "`ceil 123.001` will return `124.0`.", + }, + "chunk": {}, + "clean": {}, + "coalesce": {}, + "compact": { + Description: "Accepts a list and removes entries with empty values.", + Parameters: []string{"List"}, + }, + "concat": { + Description: "Concatenates arbitrary number of lists into one.", + Parameters: []string{"List", "..."}, + }, + "contains": { + Description: "Tests if one string is contained inside of another.", + Parameters: []string{"Substring", "String"}, + Example: "`contains \"cat\" \"catch\"` returns `true`.", + }, + "date": { + Description: "Formats date. See https://pauladamsmith.com/blog/2011/05/go_time.html.", + Parameters: []string{"Date layout"}, + }, + "dateInZone": { + Description: "Same as `date` but with a timezone.", + Parameters: []string{"Date layout", "Date to format", "Timezone"}, + Example: "`dateInZone \"2006-01-02\" (now) \"UTC\"`.", + }, + "dateModify": { + Description: "Allows date modifications.", + Parameters: []string{"Date modification", "Date"}, + Example: "`now | dateModify \"-1.5h\"` will subtract an hour and thirty minutes from the current time.", + }, + "decryptAES": { + Description: "Receives a Base64 string encoded by the AES-256 CBC algorithm and returns the decoded text.", + Parameters: []string{"Base64 string encoded by the AES-256 CBC algorithm"}, + }, + "deepCopy": { + Description: "Makes deep copy of the value. This includes maps and other structures. It will panic if there is a problem.", + Parameters: []string{"Value to copy"}, + Example: "`dict \"a\" 1 \"b\" 2 | deepCopy`.", + }, + "deepEqual": {}, + "default": {}, + "derivePassword": {}, + "dict": {}, + "dig": {}, + "dir": {}, + "div": { + Description: "Performs integer division.", + }, + "divf": { + Description: "Performs float number division.", + }, + "duration": { + Description: "Formats a given amount of seconds as a `time.Duration`.", + Parameters: []string{"Amount of seconds"}, + Example: "`duration \"95\"` returns `1m35s`.", + }, + "durationRound": {}, + "empty": { + Description: "Returns true if given value has the zero value for its type.", + Parameters: []string{"Value"}, + Example: "`empty .Foo`.", + }, + "encryptAES": { + Description: "Encrypts text with AES-256 CBC and returns a Base64 encoded string.", + Parameters: []string{"Secret key", "Text to encrypt"}, + Example: "`encryptAES \"secretkey\" \"plaintext\"`.", + }, + "env": { + Description: "Reads environment variable.", + Parameters: []string{"Environment variable name"}, + Example: "`env \"HOME\"`", + }, + "expandenv": { + Description: "Substitutes environment variable in a string.", + Parameters: []string{"String to expand"}, + Example: "`expandenv \"Your path is set to $PATH\"`", + }, + "ext": { + Description: "Returns file extension.", + Parameters: []string{"File path"}, + Example: "`ext \"foo.bar\"` will return `\"bar\"`", + }, + "fail": { + Description: "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: []string{"Error message"}, + Example: "`fail \"Please accept the end user license agreement\"`", + }, + "first": { + Description: "Returns head item on a list.", + Parameters: []string{"List"}, + }, + "float64": { + Description: "Converts to a `float64`", + Parameters: []string{"Value to convert, it can be for example an integer or a string"}, + }, + "floor": { + Description: "Returns the greatest float value greater than or equal to input value.", + Parameters: []string{"Input value"}, + Example: "`floor 123.9999` will return `123.0`", + }, + "fromJson": { + Description: "Decodes a JSON document into a structure. If the input cannot be decoded as JSON the function will return an empty string.", + Parameters: []string{"JSON document"}, + Example: "`fromJson \"{\\\"foo\\\": 55}\"`.", + }, + "genCA": { + Description: "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: []string{"Subject common name (CN)", "Cert validity duration in days"}, + }, + "genCAWithKey": { + Description: "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: []string{"Subject common name (CN)", "Cert validity duration in days", "private key (PEM-encoded; DSA keys are not supported)"}, + }, + "genPrivateKey": { + Description: "Generates a new private key encoded into a PEM block.", + Parameters: []string{"Key type (ecdsa, dsa, rsa or ed25519)"}, + }, + "genSelfSignedCert": { + Description: "Generates an SSL self-signed certificate.", + }, + "genSelfSignedCertWithKey": {}, + "genSignedCert": { + Description: "Generates an SSL certificate and key based on a given CA.", + }, + "genSignedCertWithKey": {}, + "get": {}, + "getHostByName": {}, + "has": { + Description: "Checks if a list has a particular element. It will panic if there is a problem.", + Parameters: []string{"Element to find", "List"}, + Example: "`has 4 $myList`", + }, + "hasKey": { + Description: "Checks if given dictionary contains given key.", + Parameters: []string{"Map", "Key to find"}, + }, + "hasPrefix": { + Description: "Check if string has given prefix.", + Parameters: []string{"Prefix", "String"}, + }, + "hasSuffix": { + Description: "Check if string has given suffix.", + Parameters: []string{"Prefix", "Suffix"}, + }, + "htmlDate": { + Description: "Formats a date for inserting into HTML date picker input field.", + Parameters: []string{"Date"}, + Example: "`now | htmlDate`.", + }, + "htmlDateInZone": { + Description: "Same as `htmlDate` but with a timezone.", + Parameters: []string{"Date", "Timezone"}, + Example: "`htmlDateInZone (now) \"UTC\"`.", + }, + "htpasswd": {}, + "indent": {}, + "initial": { + Description: "Compliments `last` by retuning all but the last element. It will panic if there is a problem.", + Parameters: []string{"List"}, + }, + "initials": {}, + "int": { + Description: "Converts to a `int`.", + Parameters: []string{"Value to convert"}, + }, + "int64": { + Description: "Converts to a `int64`.", + Parameters: []string{"Value to convert"}, + }, + "isAbs": { + Description: "Checks whether a path is absolute.", + Parameters: []string{"File path"}, + }, + "join": {}, + "kebabcase": { + Description: "Converts a string from camelCase to kebab-case.", + Parameters: []string{"String to convert"}, + Example: "`kebabcase \"FirstName\"` returns `first-name`.", + }, + "keys": { + Description: "Returns list of all keys from a map.", + Parameters: []string{"Map"}, + }, + "kindIs": {}, + "kindOf": {}, + "last": {}, + "list": {}, + "lower": { + Description: "Converts the entire string to lowercase.", + Parameters: []string{"String to transform"}, + Example: "`upper \\\"HELLO\\\"` will return `hello`.", + }, + "max": { + Description: "Returns the largest of a series of integers.", + Parameters: []string{"Number", "Number", "..."}, + Example: "`max 1 2 3` will return `3`.", + }, + "maxf": { + Description: "Returns the largest of a series of floats.", + Parameters: []string{"Float number", "Float number", "..."}, + Example: "`max 1 2 3.65` will return `3.65`.", + }, + "merge": {}, + "mergeOverwrite": {}, + "min": { + Description: "Returns the smallest of a series of integers.", + Parameters: []string{"Number", "Number", "..."}, + Example: "`min 1 2 3` will return `1`.", + }, + "minf": { + Description: "Returns the smallest of a series of floats.", + Parameters: []string{"Float number", "Float number", "..."}, + Example: "`min 1.3 2 3` will return `1.3`.", + }, + "mod": {}, + "mul": { + Description: "Multiplies numbers. Accepts two or more inputs.", + Parameters: []string{"Number", "Number", "..."}, + Example: "`mul 1 2 3` will return `6`.", + }, + "mulf": { + Description: "Multiplies float numbers. Accepts two or more inputs.", + Parameters: []string{"Float number", "Float number", "..."}, + Example: "`mulf 1.5 2 2` returns `6`.", + }, + "mustAppend": { + Description: "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: []string{"List", "Item to append"}, + Example: "`mustAppend ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`.", + }, + "mustChunk": {}, + "mustCompact": { + Description: "Accepts a list and removes entries with empty values. It will return an error to the template engine if there is a problem.", + Parameters: []string{"List"}, + }, + "mustDateModify": {}, + "mustDeepCopy": {}, + "mustFirst": { + Description: "Returns head item on a list. It will return an error to the template engine if there is a problem.", + Parameters: []string{"List"}, + Example: "`mustFirst $myList`", + }, + "mustFromJson": {}, + "mustHas": { + Description: "Checks if a list has a particular element. It will return an error to the template engine if there is a problem.", + Parameters: []string{"Element to find", "List"}, + Example: "`mustHas 4 $myList`", + }, + "mustInitial": { + Description: "Compliments `last` by retuning all but the last element. It will return an error to the template engine ifd there is a problem.", + Parameters: []string{"List"}, + Example: "`mustInitial $myList`", + }, + "mustLast": {}, + "mustMerge": {}, + "mustMergeOverwrite": {}, + "mustPrepend": {}, + "mustPush": {}, + "mustRegexFind": {}, + "mustRegexFindAll": {}, + "mustRegexMatch": {}, + "mustRegexReplaceAll": {}, + "mustRegexReplaceAllLiteral": {}, + "mustRegexSplit": {}, + "mustRest": { + Description: "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: []string{"List"}, + Example: "`mustRest $myList`", + }, + "mustReverse": { + Description: "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: []string{"List"}, + Example: "`mustReverse $myList`", + }, + "mustSlice": {}, + "mustToDate": { + Description: "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: []string{"Date layout", "Date string"}, + }, + "mustToJson": {}, + "mustToPrettyJson": {}, + "mustToRawJson": {}, + "mustUniq": { + Description: "Generates a list with all of the duplicates removed. It will return an error to the template engine if there is a problem.", + Parameters: []string{"List"}, + }, + "mustWithout": { + Description: "Filters items out of a list. It will return an error to the template engine if there is a problem.", + Parameters: []string{"CList", "Item to filter out"}, + Example: "`mustWithout ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`.", + }, + "nindent": {}, + "nospace": { + Description: "Removes all whitespace from a string.", + Parameters: []string{"String to transform"}, + Example: "`nospace \"hello w o r l d\"` will return `helloworld`.", + }, + "omit": {}, + "osBase": { + Description: "Returns the last element of a file path.", + Parameters: []string{"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.", + }, + "osClean": { + Description: "Cleans up a path.", + Parameters: []string{"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.", + }, + "osDir": { + Description: "Returns the directory, stripping the last part of the path.", + Parameters: []string{"File path"}, + Example: "`osDir \"/foo/bar/baz\"` returns `/foo/bar` on Linux, and `osDir \"C:\\\\foo\\\\bar\\\\baz\"` returns `C:\\\\foo\\\\bar` on Windows.", + }, + "osExt": { + Description: "Return the file extension.", + Parameters: []string{"File path"}, + Example: "`osExt \"/foo.bar\"` and `osExt \"C:\\\\foo.bar\"` will return `.bar` on Linux and Windows, respectively.", + }, + "osIsAbs": { + Description: "Checks whether a file path is absolute.", + Parameters: []string{"File path"}, + }, + "pick": {}, + "pluck": {}, + "plural": {}, + "prepend": {}, + "push": {}, + "quote": {}, + "randAlpha": {}, + "randAlphaNum": {}, + "randAscii": {}, + "randBytes": { + Description: "Accepts a count and generates cryptographically secure random sequence of bytes. The sequence is returned as a Base64 encoded string.", + Parameters: []string{"Number of bytes to generate"}, + }, + "randInt": { + Description: "Returns a random integer value from min (inclusive) to max (exclusive).", + Parameters: []string{"Min value (inclusive)", "Max value (exclusive)"}, + Example: " `randInt 12 30` will produce a random number in the range from 12 to 30.", + }, + "randNumeric": {}, + "regexFind": {}, + "regexFindAll": {}, + "regexMatch": {}, + "regexQuoteMeta": {}, + "regexReplaceAll": {}, + "regexReplaceAllLiteral": {}, + "regexSplit": {}, + "repeat": {}, + "replace": {}, + "rest": { + Description: "Gets tail of the list (everything but the first item).", + Parameters: []string{"List"}, + }, + "reverse": { + Description: "Produces a new list with the reversed elements of the given list.", + Parameters: []string{"List"}, + }, + "round": { + Description: "Returns a float value with the remainder rounded to the given number to digits after the decimal point.", + Parameters: []string{"Float number", "Number of digits to round to"}, + Example: "`round 123.55555 3` will return `123.556`.", + }, + "semver": {}, + "semverCompare": {}, + "seq": { + Description: "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`.", + }, + "set": {}, + "sha1sum": {}, + "sha256sum": { + Description: "Generates SHA256 hash of an input.", + Parameters: []string{"Input value"}, + }, + "sha512sum": { + Description: "Generates SHA512 hash of an input.", + Parameters: []string{"Input value"}, + Example: "`sha512sum \"Hello world!\"`.", + }, + "shuffle": { + Description: "Shuffles a string.", + Parameters: []string{"String to shuffle"}, + Example: "`shuffle \"hello\"`.", + }, + "slice": {}, + "snakecase": { + Description: "Converts a string from camelCase to snake_case.", + Parameters: []string{"String to convert"}, + Example: "`camelcase \"FirstName\"` returns `first_name`.", + }, + "sortAlpha": {}, + "split": {}, + "splitList": {}, + "splitn": {}, + "squote": {}, + "sub": {}, + "subf": {}, + "substr": {}, + "swapcase": { + Description: "Swaps the case of a string using a word based algorithm.", + Parameters: []string{"String to convert"}, + Example: "`swapcase \"This Is A.Test\"` returns `tHIS iS a.tEST`.", + }, + "ternary": { + Description: "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: []string{"First value", "Second value", "Test value"}, + Example: "`ternary \"foo\" \"bar\" true` or `true | \"foo\" \"bar\"` will return `\"foo\"`.", + }, + "title": { + Description: "Converts a string to title case.", + Parameters: []string{"String"}, + Example: "`title \"hello world\"` returns `\"Hello World\"`.", + }, + "toDate": { + Description: "Converts a string to a date. If the string can’t be converted it returns the zero value.", + Parameters: []string{"Date layout", "Date string"}, + }, + "toDecimal": { + Description: "Converts a Unix octal to a `int64`.", + Parameters: []string{"Unix octal"}, + Example: "`\"0777\" | toDecimal` will convert `0777` to `511` and return the value as `int64`.", + }, + "toJson": { + Description: "Encodes an item into JSON string. If the item cannot be converted to JSON the function will return an empty string.", + Parameters: []string{"An item to encode"}, + Example: "`toJson .Item` returns JSON string representation of `.Item`.", + }, + "toPrettyJson": { + Description: "Encodes an item into pretty (intended) JSON string.", + Parameters: []string{"An item to encode"}, + Example: "`toPrettyJson .Item` returns intended JSON string representation of `.Item`.", + }, + "toRawJson": { + Description: "Encodes an item into JSON string with HTML characters unescaped.", + Parameters: []string{"An item to encode"}, + Example: "`toRawJson .Item` returns unescaped JSON string representation of `.Item`.", + }, + "toString": { + Description: "Converts to a string.", + Parameters: []string{"Value"}, + }, + "toStrings": { + Description: "Converts a list, slice or array to a list of strings.", + Parameters: []string{"List"}, + Example: "`list 1 2 3 | toString` converts `1`, `2` and `3` to strings and then returns them as a list.", + }, + "trim": { + Description: "Removes space from either side of a string.", + Parameters: []string{"String to trim"}, + Example: "`trim \" hello \"` will return `hello`.", + }, + "trimAll": { + Description: "Removes given characters from the front or back of a string.", + Parameters: []string{"Character to remove", "String to trim"}, + Example: "`trimAll \"$\" \"$5.00\"` will return `5.00` (as a string).", + }, + "trimPrefix": { + Description: "Trims just the prefix from a string.", + Parameters: []string{"Character to remove", "String to trim"}, + Example: "`trimPrefix \"-\" \"-hello\"` will return `hello`.", + }, + "trimSuffix": { + Description: "Trims just the suffix from a string.", + Parameters: []string{"Character to remove", "String to trim"}, + Example: "`trimSuffix \"-\" \"hello-\"` will return `hello`.", + }, + "trimall": {}, + "trunc": {}, + "tuple": {}, + "typeIs": {}, + "typeIsLike": {}, + "typeOf": {}, + "uniq": { + Description: "Generates a list with all of the duplicates removed.", + Parameters: []string{"List"}, + }, + "unixEpoch": { + Description: "Returns the seconds since the Unix epoch for a time.", + Parameters: []string{"Time (`time.Time`)"}, + Example: "`now | unixEpoch`", + }, + "unset": { + Description: "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: []string{"Map", "Key of an item to delete"}, + }, + "until": { + Description: "Builds a range of integers.", + Parameters: []string{"Max value (exclusive)"}, + Example: "`until 5` will return a list `[0, 1, 2, 3, 4]`.", + }, + "untilStep": { + Description: "Like `until` generates a list of counting integers but it allows to define a start, stop and step.", + Parameters: []string{"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.", + }, + "untitle": { + Description: "Removes title casing.", + Parameters: []string{"String to transform"}, + Example: "`untitle \"Hello World\"` returns `\"hello world\"`.", + }, + "upper": { + Description: "Converts the entire string to uppercase.", + Parameters: []string{"String to transform"}, + Example: "`upper \"hello\"` returns `HELLO`", + }, + "urlJoin": { + Description: "Joins map produced by `urlParse` to produce URL string.", + Parameters: []string{"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`.", + }, + "urlParse": { + Description: "Parses string for URL and produces dict with URL parts. For more info check https://golang.org/pkg/net/url/#URL.", + Parameters: []string{"String with URL"}, + }, + "values": { + Description: "Returns list of all values from a map.", + Parameters: []string{"Map"}, + }, + "without": { + Description: "Filters items out of a list. It can take more than one filter.", + Parameters: []string{"List", "Item to filter out"}, + Example: "`without ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`.", + }, + "wrap": { + Description: "Wraps text at a given column count.", + Parameters: []string{"Column count", "Text"}, + Example: "`wrap 80 $text` will wrap the string in `$text` at 80 columns.", + }, + "wrapWith": { + Description: "Works as `wrap` but lets you specify the string to wrap with (`wrap` uses `\\n`).", + Parameters: []string{"Column count", "String to wrap with", "Text"}, + Example: "`wrapWith 5 \"\\t\" \"Hello world\"` returns `hello world` (where the whitespace is an ASCII tab character).", + }, }