From 2bff703353eb803bbb3667a7663f7d784d6af2ce Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 10:25:03 +0200 Subject: [PATCH 01/14] export template to a file and improve it --- docs/liquid-filters.md | 1048 +++++++++++++++---------------------- docs/liquid-filters.tmpl | 8 + internal/template/docs.go | 13 +- 3 files changed, 431 insertions(+), 638 deletions(-) create mode 100644 docs/liquid-filters.tmpl diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index e4cf370..88d0061 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -1,1457 +1,1249 @@ # Supported Liquid Filters -## abbrev +## `abbrev` +_Implementation_: `github.com/Masterminds/sprig/v3.abbrev` -_Implementation_: github.com/Masterminds/sprig/v3.abbrev +## `abbrevboth` -## abbrevboth +_Implementation_: `github.com/Masterminds/sprig/v3.abbrevboth` - -_Implementation_: github.com/Masterminds/sprig/v3.abbrevboth - -## add +## `add` Sums numbers. Accepts two or more inputs. `add 1 2 3` will return `6`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func15` -_Implementation_: github.com/Masterminds/sprig/v3.init.func15 - -## add1 +## `add1` Increments by 1. `add1 3` will return `4`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func14` -_Implementation_: github.com/Masterminds/sprig/v3.init.func14 - -## add1f +## `add1f` Increments float number by 1. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func21` -_Implementation_: github.com/Masterminds/sprig/v3.init.func21 - -## addf +## `addf` Sums float numbers. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func22` -_Implementation_: github.com/Masterminds/sprig/v3.init.func22 - -## adler32sum +## `adler32sum` Receives a string and computes its Adler-32 checksum. +_Implementation_: `github.com/Masterminds/sprig/v3.adler32sum` -_Implementation_: github.com/Masterminds/sprig/v3.adler32sum - -## ago +## `ago` Returns duration from current time in seconds resolution. +_Implementation_: `github.com/Masterminds/sprig/v3.dateAgo` -_Implementation_: github.com/Masterminds/sprig/v3.dateAgo - -## all +## `all` Takes a list of values ad returns true if all values are non-empty. +_Implementation_: `github.com/Masterminds/sprig/v3.all` -_Implementation_: github.com/Masterminds/sprig/v3.all - -## any +## `any` Takes a list of values ad returns true if any values are non-empty. +_Implementation_: `github.com/Masterminds/sprig/v3.any` -_Implementation_: github.com/Masterminds/sprig/v3.any - -## append +## `append` Appends a new item to existing list, creating a new list. +_Implementation_: `github.com/Masterminds/sprig/v3.push` -_Implementation_: github.com/Masterminds/sprig/v3.push - -## atoi +## `atoi` Converts a string to an integer. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func12` -_Implementation_: github.com/Masterminds/sprig/v3.init.func12 - -## b32dec +## `b32dec` Decodes string from Base32 format. +_Implementation_: `github.com/Masterminds/sprig/v3.base32decode` -_Implementation_: github.com/Masterminds/sprig/v3.base32decode - -## b32enc +## `b32enc` Encodes string with Base32 format. +_Implementation_: `github.com/Masterminds/sprig/v3.base32encode` -_Implementation_: github.com/Masterminds/sprig/v3.base32encode - -## b64dec +## `b64dec` Decodes string from Base64 format. +_Implementation_: `github.com/Masterminds/sprig/v3.base64decode` -_Implementation_: github.com/Masterminds/sprig/v3.base64decode - -## b64enc +## `b64enc` Encodes string with Base64 format. +_Implementation_: `github.com/Masterminds/sprig/v3.base64encode` -_Implementation_: github.com/Masterminds/sprig/v3.base64encode - -## base - +## `base` -_Implementation_: path.Base +_Implementation_: `path.Base` -## bcrypt +## `bcrypt` Receives a string and generates its bcrypt hash. +_Implementation_: `github.com/Masterminds/sprig/v3.bcrypt` -_Implementation_: github.com/Masterminds/sprig/v3.bcrypt +## `biggest` -## biggest +_Implementation_: `github.com/Masterminds/sprig/v3.max` - -_Implementation_: github.com/Masterminds/sprig/v3.max - -## buildCustomCert +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` -_Implementation_: github.com/Masterminds/sprig/v3.buildCustomCertificate - -## camelcase +## `camelcase` +_Implementation_: `github.com/huandu/xstrings.ToPascalCase` -_Implementation_: github.com/huandu/xstrings.ToPascalCase +## `cat` -## cat +_Implementation_: `github.com/Masterminds/sprig/v3.cat` - -_Implementation_: github.com/Masterminds/sprig/v3.cat - -## ceil +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.ceil - -## chunk - - - +## `chunk` -_Implementation_: github.com/Masterminds/sprig/v3.chunk -## clean +_Implementation_: `github.com/Masterminds/sprig/v3.chunk` +## `clean` -_Implementation_: path.Clean -## coalesce +_Implementation_: `path.Clean` +## `coalesce` -_Implementation_: github.com/Masterminds/sprig/v3.coalesce +_Implementation_: `github.com/Masterminds/sprig/v3.coalesce` -## compact +## `compact` Accepts a list and removes entries with empty values. +_Implementation_: `github.com/Masterminds/sprig/v3.compact` -_Implementation_: github.com/Masterminds/sprig/v3.compact - -## concat +## `concat` Concatenates arbitrary number of lists into one. +_Implementation_: `github.com/Masterminds/sprig/v3.concat` -_Implementation_: github.com/Masterminds/sprig/v3.concat - -## contains +## `contains` Tests if one string is contained inside of another. `contains "cat" "catch"` will return `true`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func9` -_Implementation_: github.com/Masterminds/sprig/v3.init.func9 - -## date +## `date` Formats date. +_Implementation_: `github.com/Masterminds/sprig/v3.date` -_Implementation_: github.com/Masterminds/sprig/v3.date - -## dateInZone +## `dateInZone` Same as `date` but with a timezone. +_Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` -_Implementation_: github.com/Masterminds/sprig/v3.dateInZone - -## dateModify - - +## `dateModify` -_Implementation_: github.com/Masterminds/sprig/v3.dateModify -## date_in_zone +_Implementation_: `github.com/Masterminds/sprig/v3.dateModify` +## `date_in_zone` -_Implementation_: github.com/Masterminds/sprig/v3.dateInZone +_Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` -## date_modify +## `date_modify` +_Implementation_: `github.com/Masterminds/sprig/v3.dateModify` -_Implementation_: github.com/Masterminds/sprig/v3.dateModify - -## decryptAES +## `decryptAES` Receives a Base64 string encoded by the AES-256 CBC algorithm and returns the decoded text. +_Implementation_: `github.com/Masterminds/sprig/v3.decryptAES` -_Implementation_: github.com/Masterminds/sprig/v3.decryptAES - -## deepCopy - - - - -_Implementation_: github.com/Masterminds/sprig/v3.deepCopy +## `deepCopy` -## deepEqual +_Implementation_: `github.com/Masterminds/sprig/v3.deepCopy` +## `deepEqual` -_Implementation_: reflect.DeepEqual -## default +_Implementation_: `reflect.DeepEqual` +## `default` -_Implementation_: github.com/pluralsh/polly/template.dfault -## derivePassword +_Implementation_: `github.com/pluralsh/polly/template.dfault` +## `derivePassword` -_Implementation_: github.com/Masterminds/sprig/v3.derivePassword +_Implementation_: `github.com/Masterminds/sprig/v3.derivePassword` -## dict +## `dict` +_Implementation_: `github.com/Masterminds/sprig/v3.dict` -_Implementation_: github.com/Masterminds/sprig/v3.dict +## `dig` -## dig +_Implementation_: `github.com/Masterminds/sprig/v3.dig` +## `dir` -_Implementation_: github.com/Masterminds/sprig/v3.dig -## dir +_Implementation_: `path.Dir` - - -_Implementation_: path.Dir - -## div +## `div` Performs integer division. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func17` -_Implementation_: github.com/Masterminds/sprig/v3.init.func17 - -## divf +## `divf` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func24` -_Implementation_: github.com/Masterminds/sprig/v3.init.func24 - -## duration +## `duration` Formats a given amount of seconds as a `time.Duration`. +_Implementation_: `github.com/Masterminds/sprig/v3.duration` -_Implementation_: github.com/Masterminds/sprig/v3.duration - -## durationRound - +## `durationRound` -_Implementation_: github.com/Masterminds/sprig/v3.durationRound +_Implementation_: `github.com/Masterminds/sprig/v3.durationRound` -## empty +## `empty` +_Implementation_: `github.com/Masterminds/sprig/v3.empty` -_Implementation_: github.com/Masterminds/sprig/v3.empty - -## encryptAES +## `encryptAES` Encrypts text with AES-256 CBC and returns a Base64 encoded string. +_Implementation_: `github.com/Masterminds/sprig/v3.encryptAES` -_Implementation_: github.com/Masterminds/sprig/v3.encryptAES - -## env +## `env` Reads environment variable. +_Implementation_: `os.Getenv` -_Implementation_: os.Getenv - -## expandenv +## `expandenv` Substitutes environment variable in a string. +_Implementation_: `os.ExpandEnv` -_Implementation_: os.ExpandEnv - -## ext +## `ext` Returns file extension. `ext "foo.bar"` will return `"bar"`. +_Implementation_: `path.Ext` -_Implementation_: path.Ext - -## fail +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func26` -_Implementation_: github.com/Masterminds/sprig/v3.init.func26 - -## first +## `first` Returns head item on a list. +_Implementation_: `github.com/Masterminds/sprig/v3.first` -_Implementation_: github.com/Masterminds/sprig/v3.first - -## float64 +## `float64` Converts to a `float64`. +_Implementation_: `github.com/Masterminds/sprig/v3.toFloat64` -_Implementation_: github.com/Masterminds/sprig/v3.toFloat64 - -## floor +## `floor` Returns the greatest float value greater than or equal to input value. `floor 123.9999` will return `123.0`. +_Implementation_: `github.com/Masterminds/sprig/v3.floor` -_Implementation_: github.com/Masterminds/sprig/v3.floor - -## fromJson - +## `fromJson` -_Aliases_: from_json -_Implementation_: github.com/Masterminds/sprig/v3.fromJson +_Aliases_: `from_json`\ +_Implementation_: `github.com/Masterminds/sprig/v3.fromJson` -## genCA +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthority` -_Implementation_: github.com/Masterminds/sprig/v3.generateCertificateAuthority - -## genCAWithKey +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey` -_Implementation_: github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey - -## genPrivateKey - +## `genPrivateKey` -_Implementation_: github.com/Masterminds/sprig/v3.generatePrivateKey +_Implementation_: `github.com/Masterminds/sprig/v3.generatePrivateKey` -## genSelfSignedCert +## `genSelfSignedCert` Generates an SSL self-signed certificate. +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificate` -_Implementation_: github.com/Masterminds/sprig/v3.generateSelfSignedCertificate +## `genSelfSignedCertWithKey` -## genSelfSignedCertWithKey +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey` - -_Implementation_: github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey - -## genSignedCert +## `genSignedCert` Generates an SSL certificate and key based on a given CA. +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificate` -_Implementation_: github.com/Masterminds/sprig/v3.generateSignedCertificate - -## genSignedCertWithKey - - - +## `genSignedCertWithKey` -_Implementation_: github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey -## get +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey` +## `get` -_Implementation_: github.com/Masterminds/sprig/v3.get -## getHostByName +_Implementation_: `github.com/Masterminds/sprig/v3.get` +## `getHostByName` -_Implementation_: github.com/Masterminds/sprig/v3.getHostByName +_Implementation_: `github.com/Masterminds/sprig/v3.getHostByName` -## has +## `has` Checks if a list has a particular element. +_Implementation_: `github.com/Masterminds/sprig/v3.has` -_Implementation_: github.com/Masterminds/sprig/v3.has +## `hasKey` -## hasKey +_Implementation_: `github.com/Masterminds/sprig/v3.hasKey` +## `hasPrefix` -_Implementation_: github.com/Masterminds/sprig/v3.hasKey -## hasPrefix +_Implementation_: `github.com/Masterminds/sprig/v3.init.func10` +## `hasSuffix` -_Implementation_: github.com/Masterminds/sprig/v3.init.func10 -## hasSuffix +_Implementation_: `github.com/Masterminds/sprig/v3.init.func11` - - - -_Implementation_: github.com/Masterminds/sprig/v3.init.func11 - -## htmlDate +## `htmlDate` Formats a date for inserting into HTML date picker input field. +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDate` -_Implementation_: github.com/Masterminds/sprig/v3.htmlDate - -## htmlDateInZone +## `htmlDateInZone` Same as `htmlDate` but with a timezone. +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDateInZone` -_Implementation_: github.com/Masterminds/sprig/v3.htmlDateInZone - -## htpasswd - +## `htpasswd` -_Implementation_: github.com/Masterminds/sprig/v3.htpasswd +_Implementation_: `github.com/Masterminds/sprig/v3.htpasswd` -## indent +## `indent` +_Implementation_: `github.com/pluralsh/polly/template.indent` -_Implementation_: github.com/pluralsh/polly/template.indent - -## initial +## `initial` Compliments `last` by retuning all but the last element. +_Implementation_: `github.com/Masterminds/sprig/v3.initial` -_Implementation_: github.com/Masterminds/sprig/v3.initial - -## initials - +## `initials` -_Implementation_: github.com/Masterminds/sprig/v3.initials +_Implementation_: `github.com/Masterminds/sprig/v3.initials` -## int +## `int` Converts to a `int`. +_Implementation_: `github.com/Masterminds/sprig/v3.toInt` -_Implementation_: github.com/Masterminds/sprig/v3.toInt - -## int64 +## `int64` Converts to a `int64`. +_Implementation_: `github.com/Masterminds/sprig/v3.toInt64` -_Implementation_: github.com/Masterminds/sprig/v3.toInt64 - -## isAbs +## `isAbs` Checks whether a path is absolute. +_Implementation_: `path.IsAbs` -_Implementation_: path.IsAbs - -## join +## `join` +_Implementation_: `github.com/Masterminds/sprig/v3.join` -_Implementation_: github.com/Masterminds/sprig/v3.join +## `kebabcase` -## kebabcase +_Implementation_: `github.com/huandu/xstrings.ToKebabCase` +## `keys` -_Implementation_: github.com/huandu/xstrings.ToKebabCase -## keys +_Implementation_: `github.com/Masterminds/sprig/v3.keys` +## `kindIs` -_Implementation_: github.com/Masterminds/sprig/v3.keys -## kindIs +_Implementation_: `github.com/Masterminds/sprig/v3.kindIs` +## `kindOf` -_Implementation_: github.com/Masterminds/sprig/v3.kindIs +_Implementation_: `github.com/Masterminds/sprig/v3.kindOf` -## kindOf +## `last` +_Implementation_: `github.com/Masterminds/sprig/v3.last` -_Implementation_: github.com/Masterminds/sprig/v3.kindOf +## `list` -## last +_Implementation_: `github.com/Masterminds/sprig/v3.list` - -_Implementation_: github.com/Masterminds/sprig/v3.last - -## list - - - - -_Implementation_: github.com/Masterminds/sprig/v3.list - -## lower +## `lower` Converts the entire string to lowercase. `upper "HELLO"` will return `hello`. +_Implementation_: `strings.ToLower` -_Implementation_: strings.ToLower - -## max +## `max` Returns the largest of a series of integers. `max 1 2 3` will return `3`. +_Implementation_: `github.com/Masterminds/sprig/v3.max` -_Implementation_: github.com/Masterminds/sprig/v3.max - -## maxf - +## `maxf` -_Implementation_: github.com/Masterminds/sprig/v3.maxf +_Implementation_: `github.com/Masterminds/sprig/v3.maxf` -## merge +## `merge` +_Implementation_: `github.com/Masterminds/sprig/v3.merge` -_Implementation_: github.com/Masterminds/sprig/v3.merge +## `mergeOverwrite` -## mergeOverwrite +_Implementation_: `github.com/Masterminds/sprig/v3.mergeOverwrite` - -_Implementation_: github.com/Masterminds/sprig/v3.mergeOverwrite - -## min +## `min` Returns the smallest of a series of integers. `min 1 2 3` will return `1`. +_Implementation_: `github.com/Masterminds/sprig/v3.min` -_Implementation_: github.com/Masterminds/sprig/v3.min - -## minf +## `minf` +_Implementation_: `github.com/Masterminds/sprig/v3.minf` -_Implementation_: github.com/Masterminds/sprig/v3.minf +## `mod` -## mod +_Implementation_: `github.com/Masterminds/sprig/v3.init.func18` - -_Implementation_: github.com/Masterminds/sprig/v3.init.func18 - -## mul +## `mul` Multiples numbers. Accepts two or more inputs. `mul 1 2 3` will return `6`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func19` -_Implementation_: github.com/Masterminds/sprig/v3.init.func19 - -## mulf - +## `mulf` -_Implementation_: github.com/Masterminds/sprig/v3.init.func25 +_Implementation_: `github.com/Masterminds/sprig/v3.init.func25` -## mustAppend +## `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.mustPush` -_Implementation_: github.com/Masterminds/sprig/v3.mustPush +## `mustChunk` -## mustChunk +_Implementation_: `github.com/Masterminds/sprig/v3.mustChunk` - -_Implementation_: github.com/Masterminds/sprig/v3.mustChunk - -## mustCompact +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.mustCompact - -## mustDateModify +## `mustDateModify` +_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` -_Implementation_: github.com/Masterminds/sprig/v3.mustDateModify +## `mustDeepCopy` -## mustDeepCopy +_Implementation_: `github.com/Masterminds/sprig/v3.mustDeepCopy` - -_Implementation_: github.com/Masterminds/sprig/v3.mustDeepCopy - -## mustFirst +## `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.mustFirst` -_Implementation_: github.com/Masterminds/sprig/v3.mustFirst - -## mustFromJson +## `mustFromJson` +_Implementation_: `github.com/Masterminds/sprig/v3.mustFromJson` -_Implementation_: github.com/Masterminds/sprig/v3.mustFromJson - -## mustHas +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.mustHas` -_Implementation_: github.com/Masterminds/sprig/v3.mustHas - -## mustInitial +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.mustInitial` -_Implementation_: github.com/Masterminds/sprig/v3.mustInitial - -## mustLast +## `mustLast` +_Implementation_: `github.com/Masterminds/sprig/v3.mustLast` -_Implementation_: github.com/Masterminds/sprig/v3.mustLast +## `mustMerge` -## mustMerge +_Implementation_: `github.com/Masterminds/sprig/v3.mustMerge` +## `mustMergeOverwrite` -_Implementation_: github.com/Masterminds/sprig/v3.mustMerge -## mustMergeOverwrite +_Implementation_: `github.com/Masterminds/sprig/v3.mustMergeOverwrite` +## `mustPrepend` -_Implementation_: github.com/Masterminds/sprig/v3.mustMergeOverwrite -## mustPrepend +_Implementation_: `github.com/Masterminds/sprig/v3.mustPrepend` +## `mustPush` -_Implementation_: github.com/Masterminds/sprig/v3.mustPrepend +_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` -## mustPush +## `mustRegexFind` +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFind` -_Implementation_: github.com/Masterminds/sprig/v3.mustPush +## `mustRegexFindAll` -## mustRegexFind +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFindAll` +## `mustRegexMatch` -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexFind -## mustRegexFindAll +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexMatch` +## `mustRegexReplaceAll` -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexFindAll -## mustRegexMatch +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAll` +## `mustRegexReplaceAllLiteral` -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexMatch +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral` -## mustRegexReplaceAll +## `mustRegexSplit` +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexSplit` -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexReplaceAll - -## mustRegexReplaceAllLiteral - - - - -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral - -## mustRegexSplit - - - - -_Implementation_: github.com/Masterminds/sprig/v3.mustRegexSplit - -## mustRest +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.mustRest` -_Implementation_: github.com/Masterminds/sprig/v3.mustRest - -## mustReverse +## `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.mustReverse` -_Implementation_: github.com/Masterminds/sprig/v3.mustReverse - -## mustSlice +## `mustSlice` +_Implementation_: `github.com/Masterminds/sprig/v3.mustSlice` -_Implementation_: github.com/Masterminds/sprig/v3.mustSlice - -## mustToDate +## `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_: github.com/Masterminds/sprig/v3.mustToDate - -## mustToJson - - +## `mustToJson` -_Implementation_: github.com/Masterminds/sprig/v3.mustToJson -## mustToPrettyJson +_Implementation_: `github.com/Masterminds/sprig/v3.mustToJson` +## `mustToPrettyJson` -_Implementation_: github.com/Masterminds/sprig/v3.mustToPrettyJson +_Implementation_: `github.com/Masterminds/sprig/v3.mustToPrettyJson` -## mustToRawJson +## `mustToRawJson` +_Implementation_: `github.com/Masterminds/sprig/v3.mustToRawJson` -_Implementation_: github.com/Masterminds/sprig/v3.mustToRawJson - -## mustUniq +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.mustUniq` -_Implementation_: github.com/Masterminds/sprig/v3.mustUniq - -## mustWithout +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.mustWithout` -_Implementation_: github.com/Masterminds/sprig/v3.mustWithout - -## must_date_modify +## `must_date_modify` +_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` -_Implementation_: github.com/Masterminds/sprig/v3.mustDateModify +## `nindent` -## nindent +_Implementation_: `github.com/pluralsh/polly/template.nindent` - -_Implementation_: github.com/pluralsh/polly/template.nindent - -## nospace +## `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/goutils.DeleteWhiteSpace - -## omit +## `omit` +_Implementation_: `github.com/Masterminds/sprig/v3.omit` -_Implementation_: github.com/Masterminds/sprig/v3.omit - -## osBase +## `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_: `path/filepath.Base` -_Implementation_: path/filepath.Base - -## osClean +## `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` -_Implementation_: path/filepath.Clean - -## osDir +## `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_: `path/filepath.Dir` -_Implementation_: path/filepath.Dir - -## osExt +## `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` -_Implementation_: path/filepath.Ext - -## osIsAbs +## `osIsAbs` Checks whether a file path is absolute. +_Implementation_: `path/filepath.IsAbs` -_Implementation_: path/filepath.IsAbs - -## pick - - - - -_Implementation_: github.com/Masterminds/sprig/v3.pick +## `pick` -## pluck +_Implementation_: `github.com/Masterminds/sprig/v3.pick` +## `pluck` -_Implementation_: github.com/Masterminds/sprig/v3.pluck -## plural +_Implementation_: `github.com/Masterminds/sprig/v3.pluck` +## `plural` -_Implementation_: github.com/Masterminds/sprig/v3.plural -## prepend +_Implementation_: `github.com/Masterminds/sprig/v3.plural` +## `prepend` -_Implementation_: github.com/Masterminds/sprig/v3.prepend +_Implementation_: `github.com/Masterminds/sprig/v3.prepend` -## push +## `push` +_Implementation_: `github.com/Masterminds/sprig/v3.push` -_Implementation_: github.com/Masterminds/sprig/v3.push +## `quote` -## quote +_Implementation_: `github.com/Masterminds/sprig/v3.quote` +## `randAlpha` -_Implementation_: github.com/Masterminds/sprig/v3.quote -## randAlpha +_Implementation_: `github.com/Masterminds/sprig/v3.randAlpha` +## `randAlphaNum` -_Implementation_: github.com/Masterminds/sprig/v3.randAlpha -## randAlphaNum +_Implementation_: `github.com/Masterminds/sprig/v3.randAlphaNumeric` +## `randAscii` -_Implementation_: github.com/Masterminds/sprig/v3.randAlphaNumeric +_Implementation_: `github.com/Masterminds/sprig/v3.randAscii` -## randAscii - - - - -_Implementation_: github.com/Masterminds/sprig/v3.randAscii - -## randBytes +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.randBytes - -## randInt +## `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.init.func20` -_Implementation_: github.com/Masterminds/sprig/v3.init.func20 +## `randNumeric` -## randNumeric +_Implementation_: `github.com/Masterminds/sprig/v3.randNumeric` +## `regexFind` -_Implementation_: github.com/Masterminds/sprig/v3.randNumeric -## regexFind +_Implementation_: `github.com/Masterminds/sprig/v3.regexFind` +## `regexFindAll` -_Implementation_: github.com/Masterminds/sprig/v3.regexFind -## regexFindAll +_Implementation_: `github.com/Masterminds/sprig/v3.regexFindAll` +## `regexMatch` -_Implementation_: github.com/Masterminds/sprig/v3.regexFindAll +_Implementation_: `github.com/Masterminds/sprig/v3.regexMatch` -## regexMatch +## `regexQuoteMeta` +_Implementation_: `github.com/Masterminds/sprig/v3.regexQuoteMeta` -_Implementation_: github.com/Masterminds/sprig/v3.regexMatch +## `regexReplaceAll` -## regexQuoteMeta +_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAll` +## `regexReplaceAllLiteral` -_Implementation_: github.com/Masterminds/sprig/v3.regexQuoteMeta -## regexReplaceAll +_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAllLiteral` +## `regexSplit` -_Implementation_: github.com/Masterminds/sprig/v3.regexReplaceAll -## regexReplaceAllLiteral +_Implementation_: `github.com/Masterminds/sprig/v3.regexSplit` +## `repeat` -_Implementation_: github.com/Masterminds/sprig/v3.regexReplaceAllLiteral +_Implementation_: `github.com/Masterminds/sprig/v3.init.func2` -## regexSplit +## `replace` +_Implementation_: `strings.ReplaceAll` -_Implementation_: github.com/Masterminds/sprig/v3.regexSplit - -## repeat - - - - -_Implementation_: github.com/Masterminds/sprig/v3.init.func2 - -## replace - - - - -_Implementation_: strings.ReplaceAll - -## rest +## `rest` Gets tail of the list (everything but the first item). +_Implementation_: `github.com/Masterminds/sprig/v3.rest` -_Implementation_: github.com/Masterminds/sprig/v3.rest - -## reverse +## `reverse` Produces a new list with the reversed elements of the given list. +_Implementation_: `github.com/Masterminds/sprig/v3.reverse` -_Implementation_: github.com/Masterminds/sprig/v3.reverse - -## round +## `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.round` -_Implementation_: github.com/Masterminds/sprig/v3.round +## `semver` -## semver +_Implementation_: `github.com/Masterminds/sprig/v3.semver` +## `semverCompare` -_Implementation_: github.com/Masterminds/sprig/v3.semver -## semverCompare +_Aliases_: `semver_compare`\ +_Implementation_: `github.com/Masterminds/sprig/v3.semverCompare` - -_Aliases_: semver_compare - -_Implementation_: github.com/Masterminds/sprig/v3.semverCompare - -## seq +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.seq - -## set - - - - -_Implementation_: github.com/Masterminds/sprig/v3.set - -## sha1sum - - - - -_Implementation_: github.com/Masterminds/sprig/v3.sha1sum +## `set` -## sha256sum -_Aliases_: sha26sum +_Implementation_: `github.com/Masterminds/sprig/v3.set` -_Implementation_: github.com/Masterminds/sprig/v3.sha256sum +## `sha1sum` -## sha512sum +_Implementation_: `github.com/Masterminds/sprig/v3.sha1sum` +## `sha256sum` -_Implementation_: github.com/Masterminds/sprig/v3.sha512sum -## shuffle +_Aliases_: `sha26sum`\ +_Implementation_: `github.com/Masterminds/sprig/v3.sha256sum` +## `sha512sum` -_Implementation_: github.com/huandu/xstrings.Shuffle +_Implementation_: `github.com/Masterminds/sprig/v3.sha512sum` -## slice +## `shuffle` +_Implementation_: `github.com/huandu/xstrings.Shuffle` -_Implementation_: github.com/Masterminds/sprig/v3.slice +## `slice` -## snakecase +_Implementation_: `github.com/Masterminds/sprig/v3.slice` +## `snakecase` -_Implementation_: github.com/huandu/xstrings.ToSnakeCase -## sortAlpha +_Implementation_: `github.com/huandu/xstrings.ToSnakeCase` +## `sortAlpha` -_Implementation_: github.com/Masterminds/sprig/v3.sortAlpha -## split +_Implementation_: `github.com/Masterminds/sprig/v3.sortAlpha` +## `split` -_Implementation_: github.com/Masterminds/sprig/v3.split +_Implementation_: `github.com/Masterminds/sprig/v3.split` -## splitList +## `splitList` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func13` -_Implementation_: github.com/Masterminds/sprig/v3.init.func13 +## `splitn` -## splitn +_Implementation_: `github.com/Masterminds/sprig/v3.splitn` +## `squote` -_Implementation_: github.com/Masterminds/sprig/v3.splitn -## squote +_Implementation_: `github.com/Masterminds/sprig/v3.squote` +## `sub` -_Implementation_: github.com/Masterminds/sprig/v3.squote -## sub +_Implementation_: `github.com/Masterminds/sprig/v3.init.func16` +## `subf` -_Implementation_: github.com/Masterminds/sprig/v3.init.func16 +_Implementation_: `github.com/Masterminds/sprig/v3.init.func23` -## subf +## `substr` +_Implementation_: `github.com/Masterminds/sprig/v3.substring` -_Implementation_: github.com/Masterminds/sprig/v3.init.func23 +## `swapcase` -## substr +_Implementation_: `github.com/Masterminds/goutils.SwapCase` - -_Implementation_: github.com/Masterminds/sprig/v3.substring - -## swapcase - - - - -_Implementation_: github.com/Masterminds/goutils.SwapCase - -## ternary +## `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"`. +_Implementation_: `github.com/pluralsh/polly/template.ternary` -_Implementation_: github.com/pluralsh/polly/template.ternary - -## title +## `title` Converts a string to title case. `title "hello world"` will return `"Hello World"`. +_Implementation_: `strings.Title` -_Implementation_: strings.Title - -## toDate +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.toDate` -_Implementation_: github.com/Masterminds/sprig/v3.toDate - -## toDecimal +## `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.toDecimal - -## toJson - - -_Aliases_: to_json +## `toJson` -_Implementation_: github.com/Masterminds/sprig/v3.toJson -## toPrettyJson +_Aliases_: `to_json`\ +_Implementation_: `github.com/Masterminds/sprig/v3.toJson` +## `toPrettyJson` -_Implementation_: github.com/Masterminds/sprig/v3.toPrettyJson +_Implementation_: `github.com/Masterminds/sprig/v3.toPrettyJson` -## toRawJson +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.toRawJson - -## toString +## `toString` Converts to a string. +_Implementation_: `github.com/Masterminds/sprig/v3.strval` -_Implementation_: github.com/Masterminds/sprig/v3.strval - -## toStrings +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.strslice - -## trim +## `trim` Removes space from either side of a string. `trim " hello "` will return `hello`. +_Implementation_: `strings.TrimSpace` -_Implementation_: strings.TrimSpace - -## trimAll +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.init.func4 - -## trimPrefix +## `trimPrefix` Trims just the prefix from a string. `trimPrefix "-" "-hello"` will return `hello`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func6` -_Implementation_: github.com/Masterminds/sprig/v3.init.func6 - -## trimSuffix +## `trimSuffix` Trims just the suffix from a string. `trimSuffix "-" "hello-"` will return `hello`. +_Implementation_: `github.com/Masterminds/sprig/v3.init.func5` -_Implementation_: github.com/Masterminds/sprig/v3.init.func5 - -## trimall - - - - -_Implementation_: github.com/Masterminds/sprig/v3.init.func3 - -## trunc - +## `trimall` -_Implementation_: github.com/Masterminds/sprig/v3.trunc +_Implementation_: `github.com/Masterminds/sprig/v3.init.func3` -## tuple +## `trunc` +_Implementation_: `github.com/Masterminds/sprig/v3.trunc` -_Implementation_: github.com/Masterminds/sprig/v3.list +## `tuple` -## typeIs +_Implementation_: `github.com/Masterminds/sprig/v3.list` +## `typeIs` -_Implementation_: github.com/Masterminds/sprig/v3.typeIs -## typeIsLike +_Implementation_: `github.com/Masterminds/sprig/v3.typeIs` +## `typeIsLike` -_Implementation_: github.com/Masterminds/sprig/v3.typeIsLike -## typeOf +_Implementation_: `github.com/Masterminds/sprig/v3.typeIsLike` +## `typeOf` -_Implementation_: github.com/Masterminds/sprig/v3.typeOf +_Implementation_: `github.com/Masterminds/sprig/v3.typeOf` -## uniq +## `uniq` Generates a list with all of the duplicates removed. +_Implementation_: `github.com/Masterminds/sprig/v3.uniq` -_Implementation_: github.com/Masterminds/sprig/v3.uniq - -## unixEpoch +## `unixEpoch` Returns the seconds since the Unix epoch. +_Implementation_: `github.com/Masterminds/sprig/v3.unixEpoch` -_Implementation_: github.com/Masterminds/sprig/v3.unixEpoch - -## unset +## `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. +_Implementation_: `github.com/Masterminds/sprig/v3.unset` -_Implementation_: github.com/Masterminds/sprig/v3.unset - -## until +## `until` Builds a range of integers. `until 5` will return a list `[0, 1, 2, 3, 4]`. +_Implementation_: `github.com/Masterminds/sprig/v3.until` -_Implementation_: github.com/Masterminds/sprig/v3.until - -## untilStep +## `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.untilStep` -_Implementation_: github.com/Masterminds/sprig/v3.untilStep - -## untitle +## `untitle` Removes title casing. `untitle "Hello World"` will return `"hello world"`. +_Implementation_: `github.com/Masterminds/sprig/v3.untitle` -_Implementation_: github.com/Masterminds/sprig/v3.untitle - -## upper +## `upper` Converts the entire string to uppercase. `upper "hello"` will return `HELLO`. +_Implementation_: `strings.ToUpper` -_Implementation_: strings.ToUpper - -## urlJoin +## `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`. +_Implementation_: `github.com/Masterminds/sprig/v3.urlJoin` -_Implementation_: github.com/Masterminds/sprig/v3.urlJoin - -## urlParse +## `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` -_Implementation_: github.com/Masterminds/sprig/v3.urlParse - -## values - +## `values` -_Implementation_: github.com/Masterminds/sprig/v3.values +_Implementation_: `github.com/Masterminds/sprig/v3.values` -## without +## `without` Filters items out of a list. It can take more than one filter. +_Implementation_: `github.com/Masterminds/sprig/v3.without` -_Implementation_: github.com/Masterminds/sprig/v3.without - -## wrap +## `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.init.func7` -_Implementation_: github.com/Masterminds/sprig/v3.init.func7 - -## wrapWith +## `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). - -_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..29e884e --- /dev/null +++ b/docs/liquid-filters.tmpl @@ -0,0 +1,8 @@ +# Supported Liquid Filters +{{ range . }} +## `{{ .Name }}` +{{ .Description }} + +{{ 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..d6138c3 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() { @@ -46,6 +39,6 @@ func registeredFilters() []tmpl.FilterFunction { } func generateFilterDocs(writer io.Writer, filters []tmpl.FilterFunction) error { - t := template.Must(template.New("").Funcs(sprig.TxtFuncMap()).Parse(docsTemplate)) + t := template.Must(template.New(path.Base(docsTemplate)).Funcs(sprig.TxtFuncMap()).ParseFiles(docsTemplate)) return t.Execute(writer, filters) } From 2afc8c0666e20c900c80526fe09c5facdef99d73 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 11:29:12 +0200 Subject: [PATCH 02/14] start migrating to the new structure --- template/liquid.go | 8 +- template/liquid_docs.go | 510 +++++++++++++++++++++++++--------------- 2 files changed, 332 insertions(+), 186 deletions(-) diff --git a/template/liquid.go b/template/liquid.go index 64bf2bc..fdc6b3d 100644 --- a/template/liquid.go +++ b/template/liquid.go @@ -13,10 +13,16 @@ import ( type FilterFunction struct { Name string `json:"name"` Aliases []string `json:"aliases,omitempty"` - Description string `json:"description,omitempty"` + Documentation string `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() diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 6760ddf..000313b 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -1,212 +1,352 @@ 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": "", +var functionDocs = map[string]FilterFunctionDocumentation{ + "abbrev": { + Description: "Truncates a string with ellipses.", + Parameters: []string{"Max length.", "The string."}, + Example: "`abbrev 5 \"hello world\"` returns `he...`.", + }, + "abbrevboth": { + Description: "Truncates both sides of a string with ellipses.", + Parameters: []string{"Left offset.", "Max length", "The string."}, + Example: "`abbrevboth 5 10 \"1234 5678 9123\"` returns `...5678...`.", + }, + "add": { + Description: "Sums numbers. Accepts two or more inputs.", + Parameters: []string{"A number.", "A number.", "..."}, + Example: "`add 1 2 3` returns `6`.", + }, + "add1": { + Description: "Increments by 1.", + Parameters: []string{"The number to increment."}, + Example: "`add1 3` returns `4`.", + }, + "add1f": { + Description: "Increments float number by 1.", + Parameters: []string{"The float number to increment."}, + Example: "`add1 3.0` returns `4.0`.", + }, + "addf": { + Description: "Sums float numbers. Accepts two or more inputs.", + Parameters: []string{"A float number.", "A float number.", "..."}, + Example: "`add 1.1 2.2 3.3` returns `6.6`.", + }, + "adler32sum": { + Description: "Computes Adler-32 checksum of a string.", + Parameters: []string{"The string."}, + Example: "`adler32sum \"Hello world!\"`.", + }, + "ago": { + Description: "Returns duration from current time (`time.Now`) in seconds resolution.", + Parameters: []string{"The string."}, + 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{"The list."}, + }, + "any": { + Description: "Takes a list of values ad returns true if any values are non-empty.", + Parameters: []string{"The list."}, + }, + "append": { + Description: "Appends a new item to existing list, creating a new list.", + Parameters: []string{"Existing list.", "New item."}, + Example: "`append ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`.", + }, + "atoi": { + Description: "Converts a string to an integer.", + Parameters: []string{"The string."}, + }, + "b32dec": { + Description: "Decodes string from Base32 format.", + Parameters: []string{"The string to decode."}, + }, + "b32enc": { + Description: "Encodes string with Base32 format.", + Parameters: []string{"The string to encode."}, + }, + "b64dec": { + Description: "Decodes string from Base64 format.", + Parameters: []string{"The string to decode."}, + }, + "b64enc": { + Description: "Encodes string with Base64 format.", + Parameters: []string{"The string to encode."}, + }, + "base": { + Description: "Returns the last element of a path.", + Parameters: []string{"The path."}, + Example: "`base \"foo/bar/baz\"` returns `baz`.", + }, + "bcrypt": { + Description: "Generates bcrypt hash of a string.", + Parameters: []string{"The string."}, + }, + "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": { + Description: "Returns list of all keys from a map.", + Parameters: []string{"The map."}, + }, + "kindIs": {}, + "kindOf": {}, + "last": {}, + "list": {}, + "lower": { + Description: "Converts the entire string to lowercase.", + Parameters: []string{"The string."}, + Example: "`upper \\\"HELLO\\\"` will return `hello`.", + }, + "max": { + Description: "Returns the largest of a series of integers.", + Parameters: []string{"A number.", "A number.", "..."}, + Example: "`max 1 2 3` will return `3`.", + }, + "maxf": { + Description: "Returns the largest of a series of floats.", + Parameters: []string{"A float number.", "A 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{"A number.", "A number.", "..."}, + Example: "`min 1 2 3` will return `1`.", + }, + "minf": { + Description: "Returns the smallest of a series of floats.", + Parameters: []string{"A float number.", "A float number.", "..."}, + Example: "`min 1.3 2 3` will return `1.3`.", + }, + "mod": {}, "mul": "Multiples numbers. Accepts two or more inputs. `mul 1 2 3` will return `6`.", - "mulf": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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": "", + "must_date_modify": {}, + "nindent": {}, "nospace": "Removes all whitespace from a string. `nospace \"hello w o r l d\"` will return `helloworld`.", - "omit": "", + "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": "", + "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": "", + "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": "", + "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": "", + "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).", + "title": { + Description: "Converts a string to title case.", + Parameters: []string{"The string."}, + Example: "`title \"hello world\"` returns `\"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": { + Description: "Removes space from either side of a string.", + Parameters: []string{"The string."}, + Example: "`trim \" hello \"` will return `hello`.", + }, + "trimAll": { + Description: "Removes given characters from the front or back of a string.", + Parameters: []string{"Character to remove", "The string."}, + 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", "The string."}, + Example: "`trimPrefix \"-\" \"-hello\"` will return `hello`.", + }, + "trimSuffix": { + Description: "Trims just the suffix from a string.", + Parameters: []string{"Character to remove", "The string."}, + 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{"The list."}, + }, + "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": { + Description: "Removes title casing.", + Parameters: []string{"The string."}, + Example: "`untitle \"Hello World\"` returns `\"hello world\"`.", + }, + "upper": { + Description: "Converts the entire string to uppercase.", + Parameters: []string{"The string."}, + Example: "`upper \"hello\"` returns `HELLO`", + }, + "urlJoin": { + Description: "Joins map produced by `urlParse` to produce URL string.", + Parameters: []string{"The 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{"The string with URL."}, + }, + "values": { + Description: "Returns list of all values from a map.", + Parameters: []string{"The map."}, + }, + "without": { + Description: "Filters items out of a list. It can take more than one filter.", + Parameters: []string{"Column count.", "The text."}, + 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.", "The 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.", "The text."}, + Example: "`wrapWith 5 \"\\t\" \"Hello world\"` returns `hello world` (where the whitespace is an ASCII tab character).", + }, } From 93f2e7f51cdde178c28b7e9cf86cacce1b90e26e Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 11:45:40 +0200 Subject: [PATCH 03/14] migrate to the new structure --- template/liquid_docs.go | 274 ++++++++++++++++++++++++---------------- 1 file changed, 162 insertions(+), 112 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 000313b..9a966d2 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -83,41 +83,67 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Generates bcrypt hash of a string.", Parameters: []string{"The string."}, }, - "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.", + "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": { + 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{"The list."}, + }, + "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": { + 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{"The 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": {}, @@ -130,21 +156,25 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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": {}, + "has": { + Description: "Checks if a list has a particular element. It will panic if there is a problem.", + Parameters: []string{"Element to find.", "The list."}, + Example: "`has 4 $myList`", + }, + "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": { Description: "Returns list of all keys from a map.", Parameters: []string{"The map."}, @@ -180,17 +210,29 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"A float number.", "A float number.", "..."}, Example: "`min 1.3 2 3` will return `1.3`.", }, - "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.", + "mod": {}, + "mul": { + Description: "Multiplies numbers. Accepts two or more inputs.", + Parameters: []string{"A number.", "A number.", "..."}, + Example: "`mul 1 2 3` will return `6`.", + }, + "mulf": { + Description: "Multiplies float numbers. Accepts two or more inputs.", + Parameters: []string{"A float number.", "A float number.", "..."}, + Example: "`mulf 1.5 2 2` returns `6`.", + }, + "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": { + Description: "Checks if a list has a particular element. It will return an error to the template engine ifd there is a problem.", + Parameters: []string{"Element to find.", "The list."}, + Example: "`mustHas 4 $myList`", + }, "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": {}, @@ -214,57 +256,65 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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\"`.", + "nospace": { + Description: "Removes all whitespace from a string.", + Parameters: []string{"The string."}, + Example: "`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": { + 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": "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": { Description: "Converts a string to title case.", Parameters: []string{"The string."}, From e502e8509881e6c61e04b1638b0cac590f2b0ceb Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 11:54:51 +0200 Subject: [PATCH 04/14] migrate to the new structure --- template/liquid_docs.go | 47 ++++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 9a966d2..f540b46 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -144,7 +144,10 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Returns head item on a list.", Parameters: []string{"The list."}, }, - "float64": "Converts to a `float64`.", + "float64": { + Description: "Converts to a `float64`.", + Parameters: []string{"The value to convert. It can be for example an integer or a string."}, + }, "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.", @@ -170,11 +173,20 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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": {}, + "int": { + Description: "Converts to a `int`.", + Parameters: []string{"The value to convert."}, + }, + "int64": { + Description: "Converts to a `int64`.", + Parameters: []string{"The value to convert."}, + }, + "isAbs": { + Description: "Checks whether a path is absolute.", + Parameters: []string{"The file path."}, + }, + "join": {}, + "kebabcase": {}, "keys": { Description: "Returns list of all keys from a map.", Parameters: []string{"The map."}, @@ -357,10 +369,25 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Generates a list with all of the duplicates removed.", Parameters: []string{"The list."}, }, - "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.", + "unixEpoch": { + Description: "Returns the seconds since the Unix epoch for a time.", + Parameters: []string{"The 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{"The map.", "The 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{"The string."}, From 3993ff84ebb4ee6384da3b39c965d0df7b9815df Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 12:00:59 +0200 Subject: [PATCH 05/14] migrate to the new structure --- template/liquid_docs.go | 53 ++++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index f540b46..ae3afe0 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -171,8 +171,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "htmlDateInZone": "Same as `htmlDate` but with a timezone.", "htpasswd": {}, "indent": {}, - "initial": "Compliments `last` by retuning all but the last element.", - "initials": {}, + "initial": { + Description: "Compliments `last` by retuning all but the last element. It will panic if there is a problem.", + Parameters: []string{"The list."}, + }, + "initials": {}, "int": { Description: "Converts to a `int`.", Parameters: []string{"The value to convert."}, @@ -238,14 +241,22 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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": {}, + "mustFirst": { + Description: "Returns head item on a list. It will return an error to the template engine if there is a problem.", + Parameters: []string{"The list."}, + Example: "`mustFirst $myList`", + }, + "mustFromJson": {}, "mustHas": { - Description: "Checks if a list has a particular element. It will return an error to the template engine ifd there is a problem.", + 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.", "The list."}, Example: "`mustHas 4 $myList`", }, - "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.", + "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{"The list."}, + Example: "`mustInitial $myList`", + }, "mustLast": {}, "mustMerge": {}, "mustMergeOverwrite": {}, @@ -257,17 +268,25 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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": {}, + "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{"The 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{"The list."}, + Example: "`mustReverse $myList`", + }, + "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": { Description: "Removes all whitespace from a string.", Parameters: []string{"The string."}, From 873aba38a1b3ab33dcf62e130adcf17e66d154d9 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 13:06:19 +0200 Subject: [PATCH 06/14] migrate to the new structure --- template/liquid_docs.go | 131 ++++++++++++++++++++++++++++------------ 1 file changed, 92 insertions(+), 39 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index ae3afe0..85a7e19 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -99,10 +99,16 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Accepts a list and removes entries with empty values.", Parameters: []string{"The list."}, }, - "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.", + "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": { + 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.", "The date.", "Timezone."}, + }, "dateModify": {}, "date_in_zone": {}, "date_modify": {}, @@ -116,10 +122,14 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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.", + "duration": { + Description: "Formats a given amount of seconds as a `time.Duration`.", + Parameters: []string{"Amount of seconds."}, + Example: "`duration \"95\"` returns `1m35s`.", + }, + "durationRound": {}, + "empty": {}, + "encryptAES": "Encrypts text with AES-256 CBC and returns a Base64 encoded string.", "env": { Description: "Reads environment variable.", Parameters: []string{"Environment variable name."}, @@ -307,7 +317,10 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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.", + "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)."}, @@ -323,41 +336,81 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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\"`.", + "rest": { + Description: "Gets tail of the list (everything but the first item).", + Parameters: []string{"The list"}, + }, + "reverse": { + Description: "Produces a new list with the reversed elements of the given list.", + Parameters: []string{"The 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": "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": { + 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{"The string."}, Example: "`title \"hello world\"` returns `\"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.", + "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{"The value."}, + }, + "toStrings": { + Description: "Converts a list, slice or array to a list of strings.", + Parameters: []string{"The list, slice or array."}, + 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{"The string."}, From 724716cf252f7e5f515394bb9fc701c1cc4ccf10 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 13:33:21 +0200 Subject: [PATCH 07/14] migrate to the new structure --- template/liquid_docs.go | 235 +++++++++++++++++++++++----------------- 1 file changed, 134 insertions(+), 101 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 85a7e19..72cac72 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -3,93 +3,97 @@ package template var functionDocs = map[string]FilterFunctionDocumentation{ "abbrev": { Description: "Truncates a string with ellipses.", - Parameters: []string{"Max length.", "The string."}, + 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", "The string."}, + 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{"A number.", "A number.", "..."}, + Parameters: []string{"Number to add", "Number to add", "..."}, Example: "`add 1 2 3` returns `6`.", }, "add1": { Description: "Increments by 1.", - Parameters: []string{"The number to increment."}, + Parameters: []string{"Number to increment"}, Example: "`add1 3` returns `4`.", }, "add1f": { Description: "Increments float number by 1.", - Parameters: []string{"The float number to increment."}, + 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{"A float number.", "A float number.", "..."}, + 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{"The string."}, + Parameters: []string{"String"}, Example: "`adler32sum \"Hello world!\"`.", }, "ago": { Description: "Returns duration from current time (`time.Now`) in seconds resolution.", - Parameters: []string{"The string."}, + 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{"The list."}, + Parameters: []string{"List"}, }, "any": { Description: "Takes a list of values ad returns true if any values are non-empty.", - Parameters: []string{"The list."}, + Parameters: []string{"List"}, }, "append": { Description: "Appends a new item to existing list, creating a new list.", - Parameters: []string{"Existing list.", "New item."}, + 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{"The string."}, + Parameters: []string{"String to convert"}, }, "b32dec": { Description: "Decodes string from Base32 format.", - Parameters: []string{"The string to decode."}, + Parameters: []string{"String to decode"}, }, "b32enc": { Description: "Encodes string with Base32 format.", - Parameters: []string{"The string to encode."}, + Parameters: []string{"String to encode"}, }, "b64dec": { Description: "Decodes string from Base64 format.", - Parameters: []string{"The string to decode."}, + Parameters: []string{"String to decode"}, }, "b64enc": { Description: "Encodes string with Base64 format.", - Parameters: []string{"The string to encode."}, + Parameters: []string{"String to encode"}, }, "base": { Description: "Returns the last element of a path.", - Parameters: []string{"The path."}, + Parameters: []string{"Path"}, Example: "`base \"foo/bar/baz\"` returns `baz`.", }, "bcrypt": { Description: "Generates bcrypt hash of a string.", - Parameters: []string{"The string."}, + Parameters: []string{"String"}, }, - "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": {}, + "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": {}, + "cat": {}, "ceil": { Description: "Returns greatest float value greater than or equal to input value.", - Parameters: []string{"Input value."}, + Parameters: []string{"Input value"}, Example: "`ceil 123.001` will return `124.0`.", }, "chunk": {}, @@ -97,22 +101,32 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "coalesce": {}, "compact": { Description: "Accepts a list and removes entries with empty values.", - Parameters: []string{"The list."}, + 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`.", }, - "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": { Description: "Formats date. See https://pauladamsmith.com/blog/2011/05/go_time.html.", - Parameters: []string{"Date layout."}, + Parameters: []string{"Date layout"}, }, "dateInZone": { Description: "Same as `date` but with a timezone.", - Parameters: []string{"Date layout.", "The date.", "Timezone."}, + Parameters: []string{"Date layout", "Date to format", "Timezone"}, + }, + "dateModify": {}, + "date_in_zone": {}, + "date_modify": {}, + "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"}, }, - "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": {}, @@ -124,43 +138,54 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "divf": {}, "duration": { Description: "Formats a given amount of seconds as a `time.Duration`.", - Parameters: []string{"Amount of seconds."}, + Parameters: []string{"Amount of seconds"}, Example: "`duration \"95\"` returns `1m35s`.", }, "durationRound": {}, "empty": {}, - "encryptAES": "Encrypts text with AES-256 CBC and returns a Base64 encoded string.", + "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."}, + Parameters: []string{"Environment variable name"}, Example: "`env \"HOME\"`", }, "expandenv": { Description: "Substitutes environment variable in a string.", - Parameters: []string{"String to expand."}, + Parameters: []string{"String to expand"}, Example: "`expandenv \"Your path is set to $PATH\"`", }, "ext": { Description: "Returns file extension.", - Parameters: []string{"File path."}, + 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."}, + Parameters: []string{"Error message"}, Example: "`fail \"Please accept the end user license agreement\"`", }, "first": { Description: "Returns head item on a list.", - Parameters: []string{"The list."}, + Parameters: []string{"List"}, }, "float64": { - Description: "Converts to a `float64`.", - Parameters: []string{"The value to convert. It can be for example an integer or a string."}, + 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": {}, + "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"}, }, - "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.", @@ -171,38 +196,46 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "getHostByName": {}, "has": { Description: "Checks if a list has a particular element. It will panic if there is a problem.", - Parameters: []string{"Element to find.", "The list."}, + Parameters: []string{"Element to find", "List"}, Example: "`has 4 $myList`", }, - "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": {}, + "hasKey": {}, + "hasPrefix": {}, + "hasSuffix": {}, + "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{"The list."}, + Parameters: []string{"List"}, }, "initials": {}, "int": { Description: "Converts to a `int`.", - Parameters: []string{"The value to convert."}, + Parameters: []string{"Value to convert"}, }, "int64": { Description: "Converts to a `int64`.", - Parameters: []string{"The value to convert."}, + Parameters: []string{"Value to convert"}, }, "isAbs": { Description: "Checks whether a path is absolute.", - Parameters: []string{"The file path."}, + Parameters: []string{"File path"}, }, "join": {}, "kebabcase": {}, "keys": { Description: "Returns list of all keys from a map.", - Parameters: []string{"The map."}, + Parameters: []string{"Map"}, }, "kindIs": {}, "kindOf": {}, @@ -210,40 +243,40 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "list": {}, "lower": { Description: "Converts the entire string to lowercase.", - Parameters: []string{"The string."}, + Parameters: []string{"String to transform"}, Example: "`upper \\\"HELLO\\\"` will return `hello`.", }, "max": { Description: "Returns the largest of a series of integers.", - Parameters: []string{"A number.", "A number.", "..."}, + Parameters: []string{"Number", "Number", "..."}, Example: "`max 1 2 3` will return `3`.", }, "maxf": { Description: "Returns the largest of a series of floats.", - Parameters: []string{"A float number.", "A float number.", "..."}, + 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{"A number.", "A number.", "..."}, + Parameters: []string{"Number", "Number", "..."}, Example: "`min 1 2 3` will return `1`.", }, "minf": { Description: "Returns the smallest of a series of floats.", - Parameters: []string{"A float number.", "A float number.", "..."}, + 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{"A number.", "A number.", "..."}, + Parameters: []string{"Number", "Number", "..."}, Example: "`mul 1 2 3` will return `6`.", }, "mulf": { Description: "Multiplies float numbers. Accepts two or more inputs.", - Parameters: []string{"A float number.", "A float number.", "..."}, + Parameters: []string{"Float number", "Float number", "..."}, Example: "`mulf 1.5 2 2` returns `6`.", }, "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.", @@ -253,18 +286,18 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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{"The list."}, + 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.", "The list."}, + 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{"The list."}, + Parameters: []string{"List"}, Example: "`mustInitial $myList`", }, "mustLast": {}, @@ -280,12 +313,12 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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{"The list."}, + 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{"The list."}, + Parameters: []string{"List"}, Example: "`mustReverse $myList`", }, "mustSlice": {}, @@ -299,7 +332,7 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "nindent": {}, "nospace": { Description: "Removes all whitespace from a string.", - Parameters: []string{"The string."}, + Parameters: []string{"String to transform"}, Example: "`nospace \"hello w o r l d\"` will return `helloworld`.", }, "omit": {}, @@ -319,11 +352,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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."}, + 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)."}, + 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": {}, @@ -338,15 +371,15 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "replace": {}, "rest": { Description: "Gets tail of the list (everything but the first item).", - Parameters: []string{"The list"}, + Parameters: []string{"List"}, }, "reverse": { Description: "Produces a new list with the reversed elements of the given list.", - Parameters: []string{"The 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."}, + Parameters: []string{"Float number", "Number of digits to round to"}, Example: "`round 123.55555 3` will return `123.556`.", }, "semver": {}, @@ -370,65 +403,65 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "swapcase": {}, "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"}, + 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{"The string."}, + 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."}, + Parameters: []string{"Date layout", "Date string"}, }, "toDecimal": { Description: "Converts a Unix octal to a `int64`.", - Parameters: []string{"Unix octal."}, + 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."}, + 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."}, + 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."}, + Parameters: []string{"An item to encode"}, Example: "`toRawJson .Item` returns unescaped JSON string representation of `.Item`.", }, "toString": { Description: "Converts to a string.", - Parameters: []string{"The value."}, + Parameters: []string{"Value"}, }, "toStrings": { Description: "Converts a list, slice or array to a list of strings.", - Parameters: []string{"The list, slice or array."}, + 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{"The 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", "The 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", "The 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", "The string."}, + Parameters: []string{"Character to remove", "String to trim"}, Example: "`trimSuffix \"-\" \"hello-\"` will return `hello`.", }, "trimall": {}, @@ -439,63 +472,63 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "typeOf": {}, "uniq": { Description: "Generates a list with all of the duplicates removed.", - Parameters: []string{"The list."}, + Parameters: []string{"List"}, }, "unixEpoch": { Description: "Returns the seconds since the Unix epoch for a time.", - Parameters: []string{"The time (`time.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{"The map.", "The key of an item to delete."}, + Parameters: []string{"Map", "Key of an item to delete"}, }, "until": { Description: "Builds a range of integers.", - Parameters: []string{"Max value (exclusive)."}, + 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."}, + 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{"The string."}, + Parameters: []string{"String to transform"}, Example: "`untitle \"Hello World\"` returns `\"hello world\"`.", }, "upper": { Description: "Converts the entire string to uppercase.", - Parameters: []string{"The string."}, + Parameters: []string{"String to transform"}, Example: "`upper \"hello\"` returns `HELLO`", }, "urlJoin": { Description: "Joins map produced by `urlParse` to produce URL string.", - Parameters: []string{"The map produced by `urlParse`."}, + 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{"The string with URL."}, + Parameters: []string{"String with URL"}, }, "values": { Description: "Returns list of all values from a map.", - Parameters: []string{"The map."}, + Parameters: []string{"Map"}, }, "without": { Description: "Filters items out of a list. It can take more than one filter.", - Parameters: []string{"Column count.", "The text."}, + Parameters: []string{"Column count", "Text"}, 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.", "The text."}, + 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.", "The text."}, + 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).", }, } From 278591429896525611ea2406632868be30cbf255 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 13:43:43 +0200 Subject: [PATCH 08/14] finish migrating to the new structure --- template/liquid_docs.go | 127 +++++++++++++++++++++++++++------------- 1 file changed, 87 insertions(+), 40 deletions(-) diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 72cac72..dd8cbab 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -134,8 +134,10 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "dict": {}, "dig": {}, "dir": {}, - "div": "Performs integer division.", - "divf": {}, + "div": { + Description: "Performs integer division.", + }, + "divf": {}, "duration": { Description: "Formats a given amount of seconds as a `time.Duration`.", Parameters: []string{"Amount of seconds"}, @@ -186,14 +188,21 @@ var functionDocs = map[string]FilterFunctionDocumentation{ 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": "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.", + "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": {}, + "genSelfSignedCert": { + Description: "Generates an SSL self-signed certificate.", + }, "genSelfSignedCertWithKey": {}, - "genSignedCert": "Generates an SSL certificate and key based on a given CA.", - "genSignedCertWithKey": {}, - "get": {}, - "getHostByName": {}, + "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"}, @@ -279,9 +288,16 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Float number", "Float number", "..."}, Example: "`mulf 1.5 2 2` returns `6`.", }, - "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.", + "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": { @@ -321,13 +337,23 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"List"}, Example: "`mustReverse $myList`", }, - "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.", + "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": "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.", + "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]`.", + }, "must_date_modify": {}, "nindent": {}, "nospace": { @@ -335,12 +361,31 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"String to transform"}, Example: "`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.", + "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": {}, @@ -384,23 +429,25 @@ var functionDocs = map[string]FilterFunctionDocumentation{ }, "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": {}, + "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": {}, + "sha512sum": {}, + "shuffle": {}, + "slice": {}, + "snakecase": {}, + "sortAlpha": {}, + "split": {}, + "splitList": {}, + "splitn": {}, + "squote": {}, + "sub": {}, + "subf": {}, + "substr": {}, + "swapcase": {}, "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"}, @@ -518,7 +565,7 @@ var functionDocs = map[string]FilterFunctionDocumentation{ }, "without": { Description: "Filters items out of a list. It can take more than one filter.", - Parameters: []string{"Column count", "Text"}, + Parameters: []string{"List", "Item to filter out"}, Example: "`without ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`.", }, "wrap": { From 91298aab9bded20f85b844d1a8c93421a93b983e Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 13:56:45 +0200 Subject: [PATCH 09/14] add new fields to template --- docs/liquid-filters.md | 2411 +++++++++++++++++++++++++++++++------- docs/liquid-filters.tmpl | 13 +- template/liquid.go | 10 +- 3 files changed, 2000 insertions(+), 434 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index 88d0061..b81c8dd 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -1,25 +1,79 @@ # Supported Liquid Filters ## `abbrev` +Truncates a string with ellipses. + + +_Parameters_: + +- Max length + +- String to truncate + + + + +_Example_: `abbrev 5 "hello world"` returns `he...`. _Implementation_: `github.com/Masterminds/sprig/v3.abbrev` ## `abbrevboth` +Truncates both sides of a string with ellipses. + + +_Parameters_: + +- Left offset + +- Max length + +- String to truncate + + + + +_Example_: `abbrevboth 5 10 "1234 5678 9123"` returns `...5678...`. _Implementation_: `github.com/Masterminds/sprig/v3.abbrevboth` ## `add` -Sums numbers. Accepts two or more inputs. `add 1 2 3` will return `6`. +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. `add1 3` will return `4`. +Increments by 1. + + +_Parameters_: + +- Number to increment + + + + +_Example_: `add1 3` returns `4`. + _Implementation_: `github.com/Masterminds/sprig/v3.init.func14` @@ -28,22 +82,70 @@ _Implementation_: `github.com/Masterminds/sprig/v3.init.func14` Increments float number by 1. +_Parameters_: + +- Float number to increment + + + + +_Example_: `add1 3.0` returns `4.0`. + + + _Implementation_: `github.com/Masterminds/sprig/v3.init.func21` ## `addf` -Sums float numbers. +Sums float numbers. Accepts two or more inputs. + + +_Parameters_: + +- Float number + +- Float number + +- ... + + + + +_Example_: `add 1.1 2.2 3.3` returns `6.6`. + _Implementation_: `github.com/Masterminds/sprig/v3.init.func22` ## `adler32sum` -Receives a string and computes its Adler-32 checksum. +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 in seconds resolution. +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` @@ -52,58 +154,154 @@ _Implementation_: `github.com/Masterminds/sprig/v3.dateAgo` Takes a list of values ad returns true if all values are non-empty. +_Parameters_: + +- List + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.all` ## `any` Takes a list of values ad returns true if any values are non-empty. +_Parameters_: + +- List + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.any` ## `append` Appends a new item to existing list, creating a new list. +_Parameters_: + +- List + +- Item to append + + + + +_Example_: `append ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`. + + + _Implementation_: `github.com/Masterminds/sprig/v3.push` ## `atoi` Converts a string to an integer. +_Parameters_: + +- String to convert + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.init.func12` ## `b32dec` Decodes string from Base32 format. +_Parameters_: + +- String to decode + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.base32decode` ## `b32enc` Encodes string with Base32 format. +_Parameters_: + +- String to encode + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.base32encode` ## `b64dec` Decodes string from Base64 format. +_Parameters_: + +- String to decode + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.base64decode` ## `b64enc` Encodes string with Base64 format. +_Parameters_: + +- String to encode + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.base64encode` ## `base` +Returns the last element of a path. + + +_Parameters_: + +- Path + + + + +_Example_: `base "foo/bar/baz"` returns `baz`. _Implementation_: `path.Base` ## `bcrypt` -Receives a string and generates its bcrypt hash. +Generates bcrypt hash of a string. + + +_Parameters_: + +- String + + + + _Implementation_: `github.com/Masterminds/sprig/v3.bcrypt` @@ -112,10 +310,27 @@ _Implementation_: `github.com/Masterminds/sprig/v3.bcrypt` + + + + _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. +Allows customizing the certificate. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the `genSignedCert` function to sign a certificate using this CA. + + +_Parameters_: + +- Base64 encoded PEM format certificate + +- Base64 encoded PEM format private key + + + + +_Example_: `$ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-key"` + _Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` @@ -124,16 +339,35 @@ _Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` + + + + _Implementation_: `github.com/huandu/xstrings.ToPascalCase` ## `cat` + + + + _Implementation_: `github.com/Masterminds/sprig/v3.cat` ## `ceil` -Returns greatest float value greater than or equal to input value. `ceil 123.001` will return `124.0`. +Returns greatest float value greater than or equal to input value. + + +_Parameters_: + +- Input value + + + + +_Example_: `ceil 123.001` will return `124.0`. + _Implementation_: `github.com/Masterminds/sprig/v3.ceil` @@ -142,40 +376,94 @@ _Implementation_: `github.com/Masterminds/sprig/v3.ceil` + + + + _Implementation_: `github.com/Masterminds/sprig/v3.chunk` ## `clean` + + + + _Implementation_: `path.Clean` ## `coalesce` + + + + _Implementation_: `github.com/Masterminds/sprig/v3.coalesce` ## `compact` Accepts a list and removes entries with empty values. +_Parameters_: + +- List + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.compact` ## `concat` Concatenates arbitrary number of lists into one. +_Parameters_: + +- List + +- ... + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.concat` ## `contains` -Tests if one string is contained inside of another. `contains "cat" "catch"` will return `true`. +Tests if one string is contained inside of another. + + +_Parameters_: + +- Substring + +- String + + + + +_Example_: `contains "cat" "catch"` returns `true`. + _Implementation_: `github.com/Masterminds/sprig/v3.init.func9` ## `date` -Formats date. +Formats date. See https://pauladamsmith.com/blog/2011/05/go_time.html. + + +_Parameters_: + +- Date layout + + + + _Implementation_: `github.com/Masterminds/sprig/v3.date` @@ -184,1066 +472,2333 @@ _Implementation_: `github.com/Masterminds/sprig/v3.date` Same as `date` but with a timezone. +_Parameters_: + +- Date layout + +- Date to format + +- Timezone + + + + + + _Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` ## `dateModify` + + + + _Implementation_: `github.com/Masterminds/sprig/v3.dateModify` ## `date_in_zone` + + + + _Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` ## `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.deepCopy` -## `deepEqual` -_Implementation_: `reflect.DeepEqual` +_Implementation_: `github.com/Masterminds/sprig/v3.deepCopy` + +## `deepEqual` + + + + + + + +_Implementation_: `reflect.DeepEqual` + +## `default` + + + + + + + +_Implementation_: `github.com/pluralsh/polly/template.dfault` + +## `derivePassword` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.derivePassword` + +## `dict` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.dict` + +## `dig` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.dig` + +## `dir` + + + + + + + +_Implementation_: `path.Dir` + +## `div` +Performs integer division. + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func17` + +## `divf` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func24` + +## `duration` +Formats a given amount of seconds as a `time.Duration`. + + +_Parameters_: + +- Amount of seconds + + + + +_Example_: `duration "95"` returns `1m35s`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.duration` + +## `durationRound` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.durationRound` + +## `empty` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.empty` + +## `encryptAES` +Encrypts text with AES-256 CBC and returns a Base64 encoded string. + + +_Parameters_: + +- Secret key + +- Text to encrypt + + + + +_Example_: `encryptAES "secretkey" "plaintext"`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.encryptAES` + +## `env` +Reads environment variable. + + +_Parameters_: + +- Environment variable name + + + + +_Example_: `env "HOME"` + + + +_Implementation_: `os.Getenv` + +## `expandenv` +Substitutes environment variable in a string. + + +_Parameters_: + +- String to expand + + + + +_Example_: `expandenv "Your path is set to $PATH"` + + + +_Implementation_: `os.ExpandEnv` + +## `ext` +Returns file extension. + + +_Parameters_: + +- File path + + + + +_Example_: `ext "foo.bar"` will return `"bar"` + + + +_Implementation_: `path.Ext` + +## `fail` +Unconditionally returns an empty string and an error with the specified text. This is useful in scenarios where other conditionals have determined that template rendering should fail. + + +_Parameters_: + +- Error message + + + + +_Example_: `fail "Please accept the end user license agreement"` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func26` + +## `first` +Returns head item on a list. + + +_Parameters_: + +- List + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.first` + +## `float64` +Converts to a `float64` + + +_Parameters_: + +- Value to convert, it can be for example an integer or a string + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.toFloat64` + +## `floor` +Returns the greatest float value greater than or equal to input value. + + +_Parameters_: + +- Input value + + + + +_Example_: `floor 123.9999` will return `123.0` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.floor` + +## `fromJson` + + + + + + +_Aliases_: `from_json`\ +_Implementation_: `github.com/Masterminds/sprig/v3.fromJson` + +## `genCA` +Generates a new, self-signed x509 SSL Certificate Authority using 2048-bit RSA private key. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the `genSignedCert` function to sign a certificate using this CA. + + +_Parameters_: + +- Subject common name (CN) + +- Cert validity duration in days + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthority` + +## `genCAWithKey` +Generates a new, self-signed x509 SSL Certificate Authority using given private key. It returns object with PEM-encoded certificate and key. Note that the returned object can be passed to the `genSignedCert` function to sign a certificate using this CA. + + +_Parameters_: + +- Subject common name (CN) + +- Cert validity duration in days + +- private key (PEM-encoded; DSA keys are not supported) + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey` + +## `genPrivateKey` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generatePrivateKey` + +## `genSelfSignedCert` +Generates an SSL self-signed certificate. + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificate` + +## `genSelfSignedCertWithKey` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey` + +## `genSignedCert` +Generates an SSL certificate and key based on a given CA. + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificate` + +## `genSignedCertWithKey` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey` + +## `get` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.get` + +## `getHostByName` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.getHostByName` + +## `has` +Checks if a list has a particular element. It will panic if there is a problem. + + +_Parameters_: + +- Element to find + +- List + + + + +_Example_: `has 4 $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.has` + +## `hasKey` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.hasKey` + +## `hasPrefix` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func10` + +## `hasSuffix` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func11` + +## `htmlDate` +Formats a date for inserting into HTML date picker input field. + + +_Parameters_: + +- Date + + + + +_Example_: `now | htmlDate`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDate` + +## `htmlDateInZone` +Same as `htmlDate` but with a timezone. + + +_Parameters_: + +- Date + +- Timezone + + + + +_Example_: `htmlDateInZone (now) "UTC"`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.htmlDateInZone` + +## `htpasswd` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.htpasswd` + +## `indent` + + + + + + + +_Implementation_: `github.com/pluralsh/polly/template.indent` + +## `initial` +Compliments `last` by retuning all but the last element. It will panic if there is a problem. + + +_Parameters_: + +- List + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.initial` + +## `initials` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.initials` + +## `int` +Converts to a `int`. + + +_Parameters_: + +- Value to convert + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.toInt` + +## `int64` +Converts to a `int64`. + + +_Parameters_: + +- Value to convert + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.toInt64` + +## `isAbs` +Checks whether a path is absolute. + + +_Parameters_: + +- File path + + + + + + +_Implementation_: `path.IsAbs` + +## `join` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.join` + +## `kebabcase` + + + + + + + +_Implementation_: `github.com/huandu/xstrings.ToKebabCase` + +## `keys` +Returns list of all keys from a map. + + +_Parameters_: + +- Map + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.keys` + +## `kindIs` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.kindIs` + +## `kindOf` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.kindOf` + +## `last` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.last` + +## `list` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.list` + +## `lower` +Converts the entire string to lowercase. + + +_Parameters_: + +- String to transform + + + + +_Example_: `upper \"HELLO\"` will return `hello`. + + + +_Implementation_: `strings.ToLower` + +## `max` +Returns the largest of a series of integers. + + +_Parameters_: + +- Number + +- Number + +- ... + + + + +_Example_: `max 1 2 3` will return `3`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.max` + +## `maxf` +Returns the largest of a series of floats. + + +_Parameters_: + +- Float number + +- Float number + +- ... + + + + +_Example_: `max 1 2 3.65` will return `3.65`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.maxf` + +## `merge` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.merge` + +## `mergeOverwrite` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mergeOverwrite` + +## `min` +Returns the smallest of a series of integers. + + +_Parameters_: + +- Number + +- Number + +- ... + + + + +_Example_: `min 1 2 3` will return `1`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.min` + +## `minf` +Returns the smallest of a series of floats. + + +_Parameters_: + +- Float number + +- Float number + +- ... + + + + +_Example_: `min 1.3 2 3` will return `1.3`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.minf` + +## `mod` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func18` + +## `mul` +Multiplies numbers. Accepts two or more inputs. + + +_Parameters_: + +- Number + +- Number + +- ... + + + + +_Example_: `mul 1 2 3` will return `6`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func19` + +## `mulf` +Multiplies float numbers. Accepts two or more inputs. + + +_Parameters_: + +- Float number + +- Float number + +- ... + + + + +_Example_: `mulf 1.5 2 2` returns `6`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.init.func25` + +## `mustAppend` +Appends a new item to existing list, creating a new list. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + +- Item to append + + + + +_Example_: `mustAppend ( list 1 2 3 ) 5` returns `[1, 2, 3, 5]`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` + +## `mustChunk` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustChunk` + +## `mustCompact` +Accepts a list and removes entries with empty values. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustCompact` + +## `mustDateModify` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` + +## `mustDeepCopy` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustDeepCopy` + +## `mustFirst` +Returns head item on a list. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + + + + +_Example_: `mustFirst $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustFirst` + +## `mustFromJson` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustFromJson` + +## `mustHas` +Checks if a list has a particular element. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- Element to find + +- List + + + + +_Example_: `mustHas 4 $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustHas` + +## `mustInitial` +Compliments `last` by retuning all but the last element. It will return an error to the template engine ifd there is a problem. + + +_Parameters_: + +- List + + + + +_Example_: `mustInitial $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustInitial` + +## `mustLast` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustLast` + +## `mustMerge` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustMerge` + +## `mustMergeOverwrite` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustMergeOverwrite` + +## `mustPrepend` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustPrepend` + +## `mustPush` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` + +## `mustRegexFind` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFind` + +## `mustRegexFindAll` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFindAll` + +## `mustRegexMatch` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexMatch` + +## `mustRegexReplaceAll` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAll` + +## `mustRegexReplaceAllLiteral` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral` + +## `mustRegexSplit` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexSplit` + +## `mustRest` +Gets tail of the list (everything but the first item). It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + + + + +_Example_: `mustRest $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustRest` + +## `mustReverse` +Produces a new list with the reversed elements of the given list. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + + + + +_Example_: `mustReverse $myList` + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustReverse` + +## `mustSlice` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustSlice` + +## `mustToDate` +Converts a string to a date. If the string can’t be converted it returns the zero value. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- Date layout + +- Date string + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustToDate` + +## `mustToJson` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustToJson` + +## `mustToPrettyJson` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustToPrettyJson` + +## `mustToRawJson` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustToRawJson` + +## `mustUniq` +Generates a list with all of the duplicates removed. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- List + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustUniq` + +## `mustWithout` +Filters items out of a list. It will return an error to the template engine if there is a problem. + + +_Parameters_: + +- CList + +- Item to filter out + + + + +_Example_: `mustWithout ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`. + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustWithout` + +## `must_date_modify` + + + + + + + +_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` + +## `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_: -## `default` +- Min value (inclusive) +- Max value (exclusive) -_Implementation_: `github.com/pluralsh/polly/template.dfault` -## `derivePassword` +_Example_: `randInt 12 30` will produce a random number in the range from 12 to 30. -_Implementation_: `github.com/Masterminds/sprig/v3.derivePassword` -## `dict` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func20` +## `randNumeric` -_Implementation_: `github.com/Masterminds/sprig/v3.dict` -## `dig` -_Implementation_: `github.com/Masterminds/sprig/v3.dig` -## `dir` +_Implementation_: `github.com/Masterminds/sprig/v3.randNumeric` +## `regexFind` -_Implementation_: `path.Dir` -## `div` -Performs integer division. -_Implementation_: `github.com/Masterminds/sprig/v3.init.func17` -## `divf` +_Implementation_: `github.com/Masterminds/sprig/v3.regexFind` +## `regexFindAll` -_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.regexFindAll` -_Implementation_: `github.com/Masterminds/sprig/v3.durationRound` +## `regexMatch` -## `empty` -_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.encryptAES` +_Implementation_: `github.com/Masterminds/sprig/v3.regexMatch` -## `env` -Reads environment variable. +## `regexQuoteMeta` -_Implementation_: `os.Getenv` -## `expandenv` -Substitutes environment variable in a string. -_Implementation_: `os.ExpandEnv` -## `ext` -Returns file extension. `ext "foo.bar"` will return `"bar"`. +_Implementation_: `github.com/Masterminds/sprig/v3.regexQuoteMeta` -_Implementation_: `path.Ext` +## `regexReplaceAll` -## `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. -_Implementation_: `github.com/Masterminds/sprig/v3.init.func26` -## `first` -Returns head item on a list. -_Implementation_: `github.com/Masterminds/sprig/v3.first` -## `float64` -Converts to a `float64`. +_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAll` +## `regexReplaceAllLiteral` -_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`. -_Implementation_: `github.com/Masterminds/sprig/v3.floor` -## `fromJson` -_Aliases_: `from_json`\ -_Implementation_: `github.com/Masterminds/sprig/v3.fromJson` +_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAllLiteral` -## `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. +## `regexSplit` -_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. -_Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey` -## `genPrivateKey` +_Implementation_: `github.com/Masterminds/sprig/v3.regexSplit` +## `repeat` -_Implementation_: `github.com/Masterminds/sprig/v3.generatePrivateKey` -## `genSelfSignedCert` -Generates an SSL self-signed certificate. -_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificate` -## `genSelfSignedCertWithKey` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func2` -_Implementation_: `github.com/Masterminds/sprig/v3.generateSelfSignedCertificateWithPEMKey` +## `replace` -## `genSignedCert` -Generates an SSL certificate and key based on a given CA. -_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificate` -## `genSignedCertWithKey` -_Implementation_: `github.com/Masterminds/sprig/v3.generateSignedCertificateWithPEMKey` +_Implementation_: `strings.ReplaceAll` -## `get` +## `rest` +Gets tail of the list (everything but the first item). +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.get` +- List -## `getHostByName` -_Implementation_: `github.com/Masterminds/sprig/v3.getHostByName` -## `has` -Checks if a list has a particular element. +_Implementation_: `github.com/Masterminds/sprig/v3.rest` -_Implementation_: `github.com/Masterminds/sprig/v3.has` +## `reverse` +Produces a new list with the reversed elements of the given list. -## `hasKey` +_Parameters_: +- List -_Implementation_: `github.com/Masterminds/sprig/v3.hasKey` -## `hasPrefix` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func10` -## `hasSuffix` +_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. -_Implementation_: `github.com/Masterminds/sprig/v3.init.func11` +_Parameters_: -## `htmlDate` -Formats a date for inserting into HTML date picker input field. +- Float number +- Number of digits to round to -_Implementation_: `github.com/Masterminds/sprig/v3.htmlDate` -## `htmlDateInZone` -Same as `htmlDate` but with a timezone. -_Implementation_: `github.com/Masterminds/sprig/v3.htmlDateInZone` +_Example_: `round 123.55555 3` will return `123.556`. -## `htpasswd` +_Implementation_: `github.com/Masterminds/sprig/v3.round` -_Implementation_: `github.com/Masterminds/sprig/v3.htpasswd` +## `semver` -## `indent` -_Implementation_: `github.com/pluralsh/polly/template.indent` -## `initial` -Compliments `last` by retuning all but the last element. -_Implementation_: `github.com/Masterminds/sprig/v3.initial` +_Implementation_: `github.com/Masterminds/sprig/v3.semver` -## `initials` +## `semverCompare` -_Implementation_: `github.com/Masterminds/sprig/v3.initials` -## `int` -Converts to a `int`. -_Implementation_: `github.com/Masterminds/sprig/v3.toInt` +_Aliases_: `semver_compare`\ +_Implementation_: `github.com/Masterminds/sprig/v3.semverCompare` -## `int64` -Converts to a `int64`. +## `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.toInt64` -## `isAbs` -Checks whether a path is absolute. -_Implementation_: `path.IsAbs` -## `join` +_Implementation_: `github.com/Masterminds/sprig/v3.seq` +## `set` -_Implementation_: `github.com/Masterminds/sprig/v3.join` -## `kebabcase` -_Implementation_: `github.com/huandu/xstrings.ToKebabCase` -## `keys` +_Implementation_: `github.com/Masterminds/sprig/v3.set` +## `sha1sum` -_Implementation_: `github.com/Masterminds/sprig/v3.keys` -## `kindIs` -_Implementation_: `github.com/Masterminds/sprig/v3.kindIs` -## `kindOf` +_Implementation_: `github.com/Masterminds/sprig/v3.sha1sum` +## `sha256sum` -_Implementation_: `github.com/Masterminds/sprig/v3.kindOf` -## `last` -_Implementation_: `github.com/Masterminds/sprig/v3.last` +_Aliases_: `sha26sum`\ +_Implementation_: `github.com/Masterminds/sprig/v3.sha256sum` -## `list` +## `sha512sum` -_Implementation_: `github.com/Masterminds/sprig/v3.list` -## `lower` -Converts the entire string to lowercase. `upper "HELLO"` will return `hello`. -_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.sha512sum` +## `shuffle` -_Implementation_: `github.com/Masterminds/sprig/v3.max` -## `maxf` -_Implementation_: `github.com/Masterminds/sprig/v3.maxf` -## `merge` +_Implementation_: `github.com/huandu/xstrings.Shuffle` +## `slice` -_Implementation_: `github.com/Masterminds/sprig/v3.merge` -## `mergeOverwrite` -_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.slice` -_Implementation_: `github.com/Masterminds/sprig/v3.min` +## `snakecase` -## `minf` -_Implementation_: `github.com/Masterminds/sprig/v3.minf` -## `mod` +_Implementation_: `github.com/huandu/xstrings.ToSnakeCase` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func18` +## `sortAlpha` -## `mul` -Multiples numbers. Accepts two or more inputs. `mul 1 2 3` will return `6`. -_Implementation_: `github.com/Masterminds/sprig/v3.init.func19` -## `mulf` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func25` +_Implementation_: `github.com/Masterminds/sprig/v3.sortAlpha` -## `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. +## `split` -_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` -## `mustChunk` -_Implementation_: `github.com/Masterminds/sprig/v3.mustChunk` -## `mustCompact` -Accepts a list and removes entries with empty values. 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.split` +## `splitList` -_Implementation_: `github.com/Masterminds/sprig/v3.mustCompact` -## `mustDateModify` -_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` -## `mustDeepCopy` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func13` +## `splitn` -_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.mustFirst` -## `mustFromJson` +_Implementation_: `github.com/Masterminds/sprig/v3.splitn` -_Implementation_: `github.com/Masterminds/sprig/v3.mustFromJson` +## `squote` -## `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. -_Implementation_: `github.com/Masterminds/sprig/v3.mustHas` -## `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. -_Implementation_: `github.com/Masterminds/sprig/v3.mustInitial` -## `mustLast` +_Implementation_: `github.com/Masterminds/sprig/v3.squote` +## `sub` -_Implementation_: `github.com/Masterminds/sprig/v3.mustLast` -## `mustMerge` -_Implementation_: `github.com/Masterminds/sprig/v3.mustMerge` -## `mustMergeOverwrite` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func16` +## `subf` -_Implementation_: `github.com/Masterminds/sprig/v3.mustMergeOverwrite` -## `mustPrepend` -_Implementation_: `github.com/Masterminds/sprig/v3.mustPrepend` -## `mustPush` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func23` +## `substr` -_Implementation_: `github.com/Masterminds/sprig/v3.mustPush` -## `mustRegexFind` -_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFind` -## `mustRegexFindAll` +_Implementation_: `github.com/Masterminds/sprig/v3.substring` +## `swapcase` -_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexFindAll` -## `mustRegexMatch` -_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexMatch` -## `mustRegexReplaceAll` +_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. -_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAll` +_Parameters_: -## `mustRegexReplaceAllLiteral` +- First value +- Second value +- Test value -_Implementation_: `github.com/Masterminds/sprig/v3.mustRegexReplaceAllLiteral` -## `mustRegexSplit` +_Example_: `ternary "foo" "bar" true` or `true | "foo" "bar"` will return `"foo"`. -_Implementation_: `github.com/Masterminds/sprig/v3.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. +_Implementation_: `github.com/pluralsh/polly/template.ternary` -_Implementation_: `github.com/Masterminds/sprig/v3.mustRest` +## `title` +Converts a string to title case. -## `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. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.mustReverse` +- String -## `mustSlice` -_Implementation_: `github.com/Masterminds/sprig/v3.mustSlice` +_Example_: `title "hello world"` returns `"Hello World"`. -## `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_: `strings.Title` -## `mustToJson` +## `toDate` +Converts a string to a date. If the string can’t be converted it returns the zero value. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.mustToJson` +- Date layout -## `mustToPrettyJson` +- Date string -_Implementation_: `github.com/Masterminds/sprig/v3.mustToPrettyJson` -## `mustToRawJson` +_Implementation_: `github.com/Masterminds/sprig/v3.toDate` -_Implementation_: `github.com/Masterminds/sprig/v3.mustToRawJson` +## `toDecimal` +Converts a Unix octal to a `int64`. -## `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. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.mustUniq` +- Unix octal -## `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. -_Implementation_: `github.com/Masterminds/sprig/v3.mustWithout` -## `must_date_modify` +_Example_: `"0777" | toDecimal` will convert `0777` to `511` and return the value as `int64`. -_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` +_Implementation_: `github.com/Masterminds/sprig/v3.toDecimal` -## `nindent` +## `toJson` +Encodes an item into JSON string. If the item cannot be converted to JSON the function will return an empty string. +_Parameters_: -_Implementation_: `github.com/pluralsh/polly/template.nindent` +- An item to encode -## `nospace` -Removes all whitespace from a string. `nospace "hello w o r l d"` will return `helloworld`. -_Implementation_: `github.com/Masterminds/goutils.DeleteWhiteSpace` -## `omit` +_Example_: `toJson .Item` returns JSON string representation of `.Item`. +_Aliases_: `to_json`\ +_Implementation_: `github.com/Masterminds/sprig/v3.toJson` -_Implementation_: `github.com/Masterminds/sprig/v3.omit` +## `toPrettyJson` +Encodes an item into pretty (intended) JSON string. -## `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. +_Parameters_: -_Implementation_: `path/filepath.Base` +- An item to encode -## `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. +_Example_: `toPrettyJson .Item` returns intended JSON string representation of `.Item`. -_Implementation_: `path/filepath.Dir` -## `osExt` -Return the file extension. `osExt "/foo.bar"` and `osExt "C:\\foo.bar"` will return `.bar` on Linux and Windows, respectively. +_Implementation_: `github.com/Masterminds/sprig/v3.toPrettyJson` +## `toRawJson` +Encodes an item into JSON string with HTML characters unescaped. -_Implementation_: `path/filepath.Ext` -## `osIsAbs` -Checks whether a file path is absolute. +_Parameters_: +- An item to encode -_Implementation_: `path/filepath.IsAbs` -## `pick` +_Example_: `toRawJson .Item` returns unescaped JSON string representation of `.Item`. -_Implementation_: `github.com/Masterminds/sprig/v3.pick` -## `pluck` +_Implementation_: `github.com/Masterminds/sprig/v3.toRawJson` +## `toString` +Converts to a string. -_Implementation_: `github.com/Masterminds/sprig/v3.pluck` -## `plural` +_Parameters_: +- Value -_Implementation_: `github.com/Masterminds/sprig/v3.plural` -## `prepend` -_Implementation_: `github.com/Masterminds/sprig/v3.prepend` +_Implementation_: `github.com/Masterminds/sprig/v3.strval` -## `push` +## `toStrings` +Converts a list, slice or array to a list of strings. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.push` +- List -## `quote` -_Implementation_: `github.com/Masterminds/sprig/v3.quote` +_Example_: `list 1 2 3 | toString` converts `1`, `2` and `3` to strings and then returns them as a list. -## `randAlpha` +_Implementation_: `github.com/Masterminds/sprig/v3.strslice` -_Implementation_: `github.com/Masterminds/sprig/v3.randAlpha` +## `trim` +Removes space from either side of a string. -## `randAlphaNum` +_Parameters_: +- String to trim -_Implementation_: `github.com/Masterminds/sprig/v3.randAlphaNumeric` -## `randAscii` +_Example_: `trim " hello "` will return `hello`. -_Implementation_: `github.com/Masterminds/sprig/v3.randAscii` -## `randBytes` -Accepts a count `N` and generates cryptographically secure random sequence of `N` bytes. The sequence is returned as a Base64 encoded string. +_Implementation_: `strings.TrimSpace` -_Implementation_: `github.com/Masterminds/sprig/v3.randBytes` +## `trimAll` +Removes given characters from the front or back of a 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. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.init.func20` +- Character to remove -## `randNumeric` +- String to trim -_Implementation_: `github.com/Masterminds/sprig/v3.randNumeric` -## `regexFind` +_Example_: `trimAll "$" "$5.00"` will return `5.00` (as a string). -_Implementation_: `github.com/Masterminds/sprig/v3.regexFind` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func4` -## `regexFindAll` +## `trimPrefix` +Trims just the prefix from a string. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.regexFindAll` +- Character to remove -## `regexMatch` +- String to trim -_Implementation_: `github.com/Masterminds/sprig/v3.regexMatch` -## `regexQuoteMeta` +_Example_: `trimPrefix "-" "-hello"` will return `hello`. -_Implementation_: `github.com/Masterminds/sprig/v3.regexQuoteMeta` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func6` -## `regexReplaceAll` +## `trimSuffix` +Trims just the suffix from a string. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAll` +- Character to remove -## `regexReplaceAllLiteral` +- String to trim -_Implementation_: `github.com/Masterminds/sprig/v3.regexReplaceAllLiteral` -## `regexSplit` +_Example_: `trimSuffix "-" "hello-"` will return `hello`. -_Implementation_: `github.com/Masterminds/sprig/v3.regexSplit` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func5` -## `repeat` +## `trimall` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func2` -## `replace` -_Implementation_: `strings.ReplaceAll` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func3` -## `rest` -Gets tail of the list (everything but the first item). +## `trunc` -_Implementation_: `github.com/Masterminds/sprig/v3.rest` -## `reverse` -Produces a new list with the reversed elements of the given 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. `round 123.55555 3` will return `123.556`. +_Implementation_: `github.com/Masterminds/sprig/v3.trunc` -_Implementation_: `github.com/Masterminds/sprig/v3.round` +## `tuple` -## `semver` -_Implementation_: `github.com/Masterminds/sprig/v3.semver` -## `semverCompare` -_Aliases_: `semver_compare`\ -_Implementation_: `github.com/Masterminds/sprig/v3.semverCompare` +_Implementation_: `github.com/Masterminds/sprig/v3.list` -## `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`. +## `typeIs` -_Implementation_: `github.com/Masterminds/sprig/v3.seq` -## `set` -_Implementation_: `github.com/Masterminds/sprig/v3.set` -## `sha1sum` +_Implementation_: `github.com/Masterminds/sprig/v3.typeIs` +## `typeIsLike` -_Implementation_: `github.com/Masterminds/sprig/v3.sha1sum` -## `sha256sum` -_Aliases_: `sha26sum`\ -_Implementation_: `github.com/Masterminds/sprig/v3.sha256sum` -## `sha512sum` +_Implementation_: `github.com/Masterminds/sprig/v3.typeIsLike` +## `typeOf` -_Implementation_: `github.com/Masterminds/sprig/v3.sha512sum` -## `shuffle` -_Implementation_: `github.com/huandu/xstrings.Shuffle` -## `slice` +_Implementation_: `github.com/Masterminds/sprig/v3.typeOf` +## `uniq` +Generates a list with all of the duplicates removed. -_Implementation_: `github.com/Masterminds/sprig/v3.slice` -## `snakecase` +_Parameters_: +- List -_Implementation_: `github.com/huandu/xstrings.ToSnakeCase` -## `sortAlpha` -_Implementation_: `github.com/Masterminds/sprig/v3.sortAlpha` +_Implementation_: `github.com/Masterminds/sprig/v3.uniq` -## `split` +## `unixEpoch` +Returns the seconds since the Unix epoch for a time. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.split` +- Time (`time.Time`) -## `splitList` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func13` +_Example_: `now | unixEpoch` -## `splitn` +_Implementation_: `github.com/Masterminds/sprig/v3.unixEpoch` -_Implementation_: `github.com/Masterminds/sprig/v3.splitn` +## `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. -## `squote` +_Parameters_: +- Map -_Implementation_: `github.com/Masterminds/sprig/v3.squote` +- Key of an item to delete -## `sub` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func16` -## `subf` +_Implementation_: `github.com/Masterminds/sprig/v3.unset` +## `until` +Builds a range of integers. -_Implementation_: `github.com/Masterminds/sprig/v3.init.func23` -## `substr` +_Parameters_: +- Max value (exclusive) -_Implementation_: `github.com/Masterminds/sprig/v3.substring` -## `swapcase` +_Example_: `until 5` will return a list `[0, 1, 2, 3, 4]`. -_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. `ternary "foo" "bar" true` or `true | "foo" "bar"` will return `"foo"`. +_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. -_Implementation_: `github.com/pluralsh/polly/template.ternary` -## `title` -Converts a string to title case. `title "hello world"` will return `"Hello World"`. +_Parameters_: +- Start value (inclusive) -_Implementation_: `strings.Title` +- Max value (exclusive) -## `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. +- Step -_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`. +_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.toDecimal` -## `toJson` +_Implementation_: `github.com/Masterminds/sprig/v3.untilStep` -_Aliases_: `to_json`\ -_Implementation_: `github.com/Masterminds/sprig/v3.toJson` +## `untitle` +Removes title casing. -## `toPrettyJson` +_Parameters_: +- String to transform -_Implementation_: `github.com/Masterminds/sprig/v3.toPrettyJson` -## `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` +_Example_: `untitle "Hello World"` returns `"hello world"`. -## `toString` -Converts to a string. -_Implementation_: `github.com/Masterminds/sprig/v3.strval` +_Implementation_: `github.com/Masterminds/sprig/v3.untitle` -## `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. +## `upper` +Converts the entire string to uppercase. -_Implementation_: `github.com/Masterminds/sprig/v3.strslice` +_Parameters_: -## `trim` -Removes space from either side of a string. `trim " hello "` will return `hello`. +- String to transform -_Implementation_: `strings.TrimSpace` -## `trimAll` -Removes given characters from the front or back of a string. `trimAll "$" "$5.00"` will return `5.00` (as a string). +_Example_: `upper "hello"` returns `HELLO` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func4` -## `trimPrefix` -Trims just the prefix from a string. `trimPrefix "-" "-hello"` will return `hello`. +_Implementation_: `strings.ToUpper` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func6` +## `urlJoin` +Joins map produced by `urlParse` to produce URL string. -## `trimSuffix` -Trims just the suffix from a string. `trimSuffix "-" "hello-"` will return `hello`. +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.init.func5` +- Map produced by `urlParse` -## `trimall` -_Implementation_: `github.com/Masterminds/sprig/v3.init.func3` +_Example_: `urlJoin (dict "fragment" "fragment" "host" "host:80" "path" "/path" "query" "query" "scheme" "http")` returns `proto://host:80/path?query#fragment`. -## `trunc` +_Implementation_: `github.com/Masterminds/sprig/v3.urlJoin` -_Implementation_: `github.com/Masterminds/sprig/v3.trunc` +## `urlParse` +Parses string for URL and produces dict with URL parts. For more info check https://golang.org/pkg/net/url/#URL. -## `tuple` +_Parameters_: +- String with URL -_Implementation_: `github.com/Masterminds/sprig/v3.list` -## `typeIs` -_Implementation_: `github.com/Masterminds/sprig/v3.typeIs` -## `typeIsLike` +_Implementation_: `github.com/Masterminds/sprig/v3.urlParse` +## `values` +Returns list of all values from a map. -_Implementation_: `github.com/Masterminds/sprig/v3.typeIsLike` +_Parameters_: -## `typeOf` +- Map -_Implementation_: `github.com/Masterminds/sprig/v3.typeOf` -## `uniq` -Generates a list with all of the duplicates removed. -_Implementation_: `github.com/Masterminds/sprig/v3.uniq` +_Implementation_: `github.com/Masterminds/sprig/v3.values` -## `unixEpoch` -Returns the seconds since the Unix epoch. +## `without` +Filters items out of a list. It can take more than one filter. -_Implementation_: `github.com/Masterminds/sprig/v3.unixEpoch` +_Parameters_: -## `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. +- List +- Item to filter out -_Implementation_: `github.com/Masterminds/sprig/v3.unset` -## `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_: `without ( list 1 2 3 4 5) 1 3 5` returns `[2, 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. -_Implementation_: `github.com/Masterminds/sprig/v3.untilStep` +_Implementation_: `github.com/Masterminds/sprig/v3.without` -## `untitle` -Removes title casing. `untitle "Hello World"` will return `"hello world"`. +## `wrap` +Wraps text at a given column count. -_Implementation_: `github.com/Masterminds/sprig/v3.untitle` +_Parameters_: -## `upper` -Converts the entire string to uppercase. `upper "hello"` will return `HELLO`. +- Column count +- Text -_Implementation_: `strings.ToUpper` -## `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`. -_Implementation_: `github.com/Masterminds/sprig/v3.urlJoin` +_Example_: `wrap 80 $text` will wrap the string in `$text` at 80 columns. -## `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` +_Implementation_: `github.com/Masterminds/sprig/v3.init.func7` -## `values` +## `wrapWith` +Works as `wrap` but lets you specify the string to wrap with (`wrap` uses `\n`). +_Parameters_: -_Implementation_: `github.com/Masterminds/sprig/v3.values` +- Column count -## `without` -Filters items out of a list. It can take more than one filter. +- String to wrap with +- Text -_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.init.func7` +_Example_: `wrapWith 5 "\t" "Hello world"` returns `hello world` (where the whitespace is an ASCII tab character). -## `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). _Implementation_: `github.com/Masterminds/sprig/v3.init.func8` diff --git a/docs/liquid-filters.tmpl b/docs/liquid-filters.tmpl index 29e884e..8bbff9c 100644 --- a/docs/liquid-filters.tmpl +++ b/docs/liquid-filters.tmpl @@ -1,7 +1,18 @@ # Supported Liquid Filters {{ range . }} ## `{{ .Name }}` -{{ .Description }} +{{ .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 }}` diff --git a/template/liquid.go b/template/liquid.go index fdc6b3d..acc0685 100644 --- a/template/liquid.go +++ b/template/liquid.go @@ -11,10 +11,10 @@ import ( ) type FilterFunction struct { - Name string `json:"name"` - Aliases []string `json:"aliases,omitempty"` - Documentation 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 { @@ -74,7 +74,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(), } } From 8d814bfa75eb1a560a936ddcbdaa84576b58c61a Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 14:48:05 +0200 Subject: [PATCH 10/14] update docs --- docs/liquid-filters.md | 78 ++++++++++++++++++++++++++++++++++++----- template/liquid.go | 13 ++++--- template/liquid_docs.go | 65 +++++++++++++++++++++++++--------- 3 files changed, 126 insertions(+), 30 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index b81c8dd..79d01c2 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -483,29 +483,30 @@ _Parameters_: +_Example_: `dateInZone "2006-01-02" (now) "UTC"`. +_Aliases_: `date_in_zone`\ _Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` ## `dateModify` +Allows date modifications. +_Parameters_: +- Date modification - - - -_Implementation_: `github.com/Masterminds/sprig/v3.dateModify` - -## `date_in_zone` - +- Date +_Example_: `now | dateModify "-1.5h"` will subtract an hour and thirty minutes from the current time. -_Implementation_: `github.com/Masterminds/sprig/v3.dateInZone` +_Aliases_: `date_modify`\ +_Implementation_: `github.com/Masterminds/sprig/v3.dateModify` ## `date_modify` @@ -533,11 +534,18 @@ _Parameters_: _Implementation_: `github.com/Masterminds/sprig/v3.decryptAES` ## `deepCopy` +Makes deep copy of the value. This includes maps and other structures. It will panic if there is a problem. + + +_Parameters_: +- Value to copy +_Example_: `dict "a" 1 "b" 2 | deepCopy`. + _Implementation_: `github.com/Masterminds/sprig/v3.deepCopy` @@ -650,10 +658,17 @@ _Implementation_: `github.com/Masterminds/sprig/v3.duration` _Implementation_: `github.com/Masterminds/sprig/v3.durationRound` ## `empty` +Returns true if given value has the zero value for its type. + + +_Parameters_: + +- Value +_Example_: `empty .Foo`. @@ -794,11 +809,18 @@ _Example_: `floor 123.9999` will return `123.0` _Implementation_: `github.com/Masterminds/sprig/v3.floor` ## `fromJson` +Decodes a JSON document into a structure. If the input cannot be decoded as JSON the function will return an empty string. +_Parameters_: + +- JSON document + +_Example_: `fromJson "{\"foo\": 55}"`. + _Aliases_: `from_json`\ _Implementation_: `github.com/Masterminds/sprig/v3.fromJson` @@ -840,7 +862,12 @@ _Parameters_: _Implementation_: `github.com/Masterminds/sprig/v3.generateCertificateAuthorityWithPEMKey` ## `genPrivateKey` +Generates a new private key encoded into a PEM block. + + +_Parameters_: +- Key type (ecdsa, dsa, rsa or ed25519) @@ -929,7 +956,14 @@ _Example_: `has 4 $myList` _Implementation_: `github.com/Masterminds/sprig/v3.has` ## `hasKey` +Checks if given dictionary contains given key. + +_Parameters_: + +- Map + +- Key to find @@ -939,8 +973,15 @@ _Implementation_: `github.com/Masterminds/sprig/v3.has` _Implementation_: `github.com/Masterminds/sprig/v3.hasKey` ## `hasPrefix` +Check if string has given prefix. +_Parameters_: + +- Prefix + +- String + @@ -949,7 +990,14 @@ _Implementation_: `github.com/Masterminds/sprig/v3.hasKey` _Implementation_: `github.com/Masterminds/sprig/v3.init.func10` ## `hasSuffix` +Check if string has given suffix. + +_Parameters_: + +- Prefix + +- Suffix @@ -1383,7 +1431,7 @@ _Implementation_: `github.com/Masterminds/sprig/v3.mustCompact` - +_Aliases_: `must_date_modify`\ _Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` ## `mustDeepCopy` @@ -2148,7 +2196,12 @@ _Implementation_: `github.com/Masterminds/sprig/v3.set` _Implementation_: `github.com/Masterminds/sprig/v3.sha1sum` ## `sha256sum` +Generates SHA256 hash of an input. + + +_Parameters_: +- Input value @@ -2158,10 +2211,17 @@ _Aliases_: `sha26sum`\ _Implementation_: `github.com/Masterminds/sprig/v3.sha256sum` ## `sha512sum` +Generates SHA512 hash of an input. + + +_Parameters_: + +- Input value +_Example_: `sha512sum "Hello world!"`. diff --git a/template/liquid.go b/template/liquid.go index acc0685..8f29e73 100644 --- a/template/liquid.go +++ b/template/liquid.go @@ -27,14 +27,17 @@ var ( liquidEngine = liquid.NewEngine() // excludedSprigFunctions contains names of Spring functions that will be excluded. - excludedSprigFunctions = []string{"hello", "now", "uuidv4"} + excludedSprigFunctions = []string{"date_in_zone", "hello", "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. diff --git a/template/liquid_docs.go b/template/liquid_docs.go index dd8cbab..2fdee40 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -119,15 +119,22 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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.", }, - "dateModify": {}, - "date_in_zone": {}, - "date_modify": {}, "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": {}, + "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": {}, @@ -144,7 +151,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Example: "`duration \"95\"` returns `1m35s`.", }, "durationRound": {}, - "empty": {}, + "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"}, @@ -183,7 +194,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Input value"}, Example: "`floor 123.9999` will return `123.0`", }, - "fromJson": {}, + "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"}, @@ -192,7 +207,10 @@ var functionDocs = map[string]FilterFunctionDocumentation{ 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": {}, + "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.", }, @@ -208,9 +226,18 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Element to find", "List"}, Example: "`has 4 $myList`", }, - "hasKey": {}, - "hasPrefix": {}, - "hasSuffix": {}, + "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"}, @@ -354,8 +381,7 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"CList", "Item to filter out"}, Example: "`mustWithout ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`.", }, - "must_date_modify": {}, - "nindent": {}, + "nindent": {}, "nospace": { Description: "Removes all whitespace from a string.", Parameters: []string{"String to transform"}, @@ -432,10 +458,17 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "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": {}, - "sha512sum": {}, + "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": {}, "slice": {}, "snakecase": {}, From a4a29223b3c50ec8ba4d9d7827b8ad862af427a3 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 14:52:24 +0200 Subject: [PATCH 11/14] fix tests --- internal/template/docs.go | 6 +++--- internal/template/docs_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/internal/template/docs.go b/internal/template/docs.go index d6138c3..262330c 100644 --- a/internal/template/docs.go +++ b/internal/template/docs.go @@ -24,7 +24,7 @@ func main() { panic(err) } - if err = generateFilterDocs(f, registeredFilters()); err != nil { + if err = generateFilterDocs(f, registeredFilters(), docsTemplate); err != nil { panic(err) } } @@ -38,7 +38,7 @@ func registeredFilters() []tmpl.FilterFunction { return filters } -func generateFilterDocs(writer io.Writer, filters []tmpl.FilterFunction) error { - t := template.Must(template.New(path.Base(docsTemplate)).Funcs(sprig.TxtFuncMap()).ParseFiles(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") From c3b895094395518a5fe254fd01cf65546451b169 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 14:55:29 +0200 Subject: [PATCH 12/14] fix tests --- docs/liquid-filters.md | 20 -------------------- template/liquid.go | 9 ++++++++- 2 files changed, 8 insertions(+), 21 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index 79d01c2..df485b7 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -506,16 +506,6 @@ _Example_: `now | dateModify "-1.5h"` will subtract an hour and thirty minutes f _Aliases_: `date_modify`\ -_Implementation_: `github.com/Masterminds/sprig/v3.dateModify` - -## `date_modify` - - - - - - - _Implementation_: `github.com/Masterminds/sprig/v3.dateModify` ## `decryptAES` @@ -1742,16 +1732,6 @@ _Example_: `mustWithout ( list 1 2 3 4 5) 1 3 5` returns `[2, 4]`. _Implementation_: `github.com/Masterminds/sprig/v3.mustWithout` -## `must_date_modify` - - - - - - - -_Implementation_: `github.com/Masterminds/sprig/v3.mustDateModify` - ## `nindent` diff --git a/template/liquid.go b/template/liquid.go index 8f29e73..0828236 100644 --- a/template/liquid.go +++ b/template/liquid.go @@ -27,7 +27,14 @@ var ( liquidEngine = liquid.NewEngine() // excludedSprigFunctions contains names of Spring functions that will be excluded. - excludedSprigFunctions = []string{"date_in_zone", "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{ From bf2dffe73f3a9b7fbb3f44338baa794dcb53f306 Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 15:00:54 +0200 Subject: [PATCH 13/14] update docs --- docs/liquid-filters.md | 2 +- template/liquid_docs.go | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index df485b7..bfa194d 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -611,7 +611,7 @@ Performs integer division. _Implementation_: `github.com/Masterminds/sprig/v3.init.func17` ## `divf` - +Performs float number division. diff --git a/template/liquid_docs.go b/template/liquid_docs.go index 2fdee40..e58c8c1 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -144,7 +144,9 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "div": { Description: "Performs integer division.", }, - "divf": {}, + "divf": { + Description: "Performs float number division.", + }, "duration": { Description: "Formats a given amount of seconds as a `time.Duration`.", Parameters: []string{"Amount of seconds"}, From 7c9747351bdbcb511dc326e590fcc7bca9fb62bb Mon Sep 17 00:00:00 2001 From: Marcin Maciaszczyk Date: Tue, 24 Sep 2024 15:41:10 +0200 Subject: [PATCH 14/14] update docs --- docs/liquid-filters.md | 35 +++++++++++++++++++++++++++++++++++ template/liquid_docs.go | 36 ++++++++++++++++++++++++++++-------- 2 files changed, 63 insertions(+), 8 deletions(-) diff --git a/docs/liquid-filters.md b/docs/liquid-filters.md index bfa194d..f3d154b 100644 --- a/docs/liquid-filters.md +++ b/docs/liquid-filters.md @@ -336,12 +336,19 @@ _Example_: `$ca := buildCustomCert "base64-encoded-ca-crt" "base64-encoded-ca-ke _Implementation_: `github.com/Masterminds/sprig/v3.buildCustomCertificate` ## `camelcase` +Converts a string from snake_case to camelCase. +_Parameters_: + +- String to convert +_Example_: `camelcase "http_server"` returns `HttpServer`. + + _Implementation_: `github.com/huandu/xstrings.ToPascalCase` @@ -1133,11 +1140,18 @@ _Implementation_: `path.IsAbs` _Implementation_: `github.com/Masterminds/sprig/v3.join` ## `kebabcase` +Converts a string from camelCase to kebab-case. + +_Parameters_: + +- String to convert +_Example_: `kebabcase "FirstName"` returns `first-name`. + _Implementation_: `github.com/huandu/xstrings.ToKebabCase` @@ -2208,10 +2222,17 @@ _Example_: `sha512sum "Hello world!"`. _Implementation_: `github.com/Masterminds/sprig/v3.sha512sum` ## `shuffle` +Shuffles a string. + + +_Parameters_: + +- String to shuffle +_Example_: `shuffle "hello"`. @@ -2228,10 +2249,17 @@ _Implementation_: `github.com/huandu/xstrings.Shuffle` _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`. @@ -2318,10 +2346,17 @@ _Implementation_: `github.com/Masterminds/sprig/v3.init.func23` _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`. diff --git a/template/liquid_docs.go b/template/liquid_docs.go index e58c8c1..91d4b20 100644 --- a/template/liquid_docs.go +++ b/template/liquid_docs.go @@ -89,8 +89,12 @@ var functionDocs = map[string]FilterFunctionDocumentation{ 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": {}, - "cat": {}, + "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"}, @@ -269,8 +273,12 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Description: "Checks whether a path is absolute.", Parameters: []string{"File path"}, }, - "join": {}, - "kebabcase": {}, + "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"}, @@ -471,9 +479,17 @@ var functionDocs = map[string]FilterFunctionDocumentation{ Parameters: []string{"Input value"}, Example: "`sha512sum \"Hello world!\"`.", }, - "shuffle": {}, - "slice": {}, - "snakecase": {}, + "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": {}, @@ -482,7 +498,11 @@ var functionDocs = map[string]FilterFunctionDocumentation{ "sub": {}, "subf": {}, "substr": {}, - "swapcase": {}, + "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"},