From d4fd86265e18df5891e3cede52e98faed8fe7c5b Mon Sep 17 00:00:00 2001 From: Sebastian Poxhofer <secustor@users.noreply.github.com> Date: Fri, 9 Aug 2024 08:02:35 +0200 Subject: [PATCH] docs(templates): order alphabetically (#30674) --- docs/usage/templates.md | 88 +++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 47 deletions(-) diff --git a/docs/usage/templates.md b/docs/usage/templates.md index 5a8e602feb..fb1fc89c5f 100644 --- a/docs/usage/templates.md +++ b/docs/usage/templates.md @@ -31,31 +31,37 @@ Some are configuration options passed through, while others are generated as par ## Additional Handlebars helpers -### stringToPrettyJSON +### and -If you want to print pretty JSON with Handlebars you can use the built-in function `stringToPrettyJSON` like this: +Returns `true` only if all expressions are `true`. -`{{{stringToPrettyJSON myvar}}}` +`{{#if (and isMajor hasReleaseNotes)}}Backwards Incompatible release! Check out the Release notes.{{/if}}` -In the example above `myvar` is a variable/field, that has valid JSON. +In the example above, it will only show a text if `isMajor=true` and `hasReleaseNotes=true`. -### toArray +### containsString -If you want to convert elements to an array, use `toArray`, e.g., +Returns `true` if a given string is a substring. -`{{{ toJSON (toArray 'value1' 'value2' 'value3') }}}` will render `["value1","value2","value3"]`. +`{{#if (containsString depName 'python')}}Python{{else}}Other{{/if}}` -### toJSON +### decodeURIComponent -If you want to convert an object to a JSON string, you can use the built-in function `toJSON` like this: +If you want to decode a percent-encoded string, use the built-in function `decodeURIComponent` like this: -`{{{ toJSON upgrades }}}` +`{{{decodeURIComponent depName}}}` -### toObject +In the example above `depName` is the string you want to decode. -If you want to convert key-value pairs to an object, use `toObject`, e.g., +Read the [MDN Web Docs, decodeURIComponent()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) to learn more. -`{{{ toJSON (toObject 'key1' 'value1' 'key2' 'value2') }}}` will render `{"key1":"value1","key2":"value2"}`. +### encodeBase64 + +If you want to convert a string to Base64, use the built-in function `encodeBase64` like this: + +`{{{encodeBase64 body}}}` + +In the example above `body` is the string you want to transform into a Base64-encoded value. ### encodeURIComponent @@ -67,23 +73,23 @@ In the example above `baseDir` is the string you want to transform into a valid Read the [MDN Web Docs, encodeURIComponent()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent) to learn more. -### decodeURIComponent +### equals -If you want to decode a percent-encoded string, use the built-in function `decodeURIComponent` like this: +Returns `true` if two values equals (checks strict equality, i.e. `===`). -`{{{decodeURIComponent depName}}}` +`{{#if (equals datasource 'git-refs')}}git-refs{{else}}Other{{/if}}` -In the example above `depName` is the string you want to decode. +### lowercase -Read the [MDN Web Docs, decodeURIComponent()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/decodeURIComponent) to learn more. +The `lowercase` helper converts a given string to lower case. -### encodeBase64 +`{{{ lowercase depName }}}` -If you want to convert a string to Base64, use the built-in function `encodeBase64` like this: +### or -`{{{encodeBase64 body}}}` +Returns `true` if at least one expression is `true`. -In the example above `body` is the string you want to transform into a Base64-encoded value. +`{{#if (or isPatch isSingleVersion}}Small update, safer to merge and release.{{else}}Check out the changelog for all versions before merging!{{/if}}` ### replace @@ -96,43 +102,31 @@ In the example above all matches of the regex `[a-z]+\.github\.com` will be repl Read the [MDN Web Docs, String.prototype.replace()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replace) to learn more. -### lowercase - -The `lowercase` helper converts a given string to lower case. - -`{{{ lowercase depName }}}` - -### containsString - -Returns `true` if a given string is a substring. - -`{{#if (containsString depName 'python')}}Python{{else}}Other{{/if}}` - -### equals +### stringToPrettyJSON -Returns `true` if two values equals (checks strict equality, i.e. `===`). +If you want to print pretty JSON with Handlebars you can use the built-in function `stringToPrettyJSON` like this: -`{{#if (equals datasource 'git-refs')}}git-refs{{else}}Other{{/if}}` +`{{{stringToPrettyJSON myvar}}}` -### and +In the example above `myvar` is a variable/field, that has valid JSON. -Returns `true` only if all expressions are `true`. +### toArray -`{{#if (and isMajor hasReleaseNotes)}}Backwards Incompatible release! Check out the Release notes.{{/if}}` +If you want to convert elements to an array, use `toArray`, e.g., -In the example above, it will only show a text if `isMajor=true` and `hasReleaseNotes=true`. +`{{{ toJSON (toArray 'value1' 'value2' 'value3') }}}` will render `["value1","value2","value3"]`. -### or +### toJSON -Returns `true` if at least one expression is `true`. +If you want to convert an object to a JSON string, you can use the built-in function `toJSON` like this: -`{{#if (or isPatch isSingleVersion}}Small update, safer to merge and release.{{else}}Check out the changelog for all versions before merging!{{/if}}` +`{{{ toJSON upgrades }}}` -### includes +### toObject -Returns `true` if the value is included on the list given. +If you want to convert key-value pairs to an object, use `toObject`, e.g., -`{{#if (includes labels 'dependencies')}}Production Dependencies{{else}}Not Production Dependencies{{/if}}` +`{{{ toJSON (toObject 'key1' 'value1' 'key2' 'value2') }}}` will render `{"key1":"value1","key2":"value2"}`. ## Environment variables -- GitLab