2020-04-07 07:23:41 +00:00
---
2020-12-13 22:32:55 +00:00
title: Template fields
2020-11-16 08:07:23 +00:00
description: Explain Renovate template fields
2020-04-07 07:23:41 +00:00
---
2020-12-13 22:32:55 +00:00
# Template fields
2020-04-07 07:23:41 +00:00
In order to provide flexible configuration, Renovate supports using "templates" for certain fields like `branchName` .
2020-11-02 08:52:37 +00:00
Renovate's templates use [handlebars ](https://handlebarsjs.com/ ) under the hood.
You can recognize templates when you see strings like `{{depName}}` in configuration fields.
2020-04-07 07:23:41 +00:00
2020-11-02 08:52:37 +00:00
Below you can find lists of fields/values that you can use in templates.
Some are configuration options passed through, while others are generated as part of Renovate's run.
2020-04-07 07:23:41 +00:00
2022-08-11 20:27:13 +00:00
`logJSON` and `releases` are only allowed in `commitBody` template.
2020-12-13 22:32:55 +00:00
## Exposed config options
2020-04-07 07:23:41 +00:00
2022-01-11 15:25:14 +00:00
<!-- Autogenerate in https://github.com/renovatebot/renovate -->
2021-12-09 20:12:49 +00:00
<!-- Autogenerate end -->
2020-04-07 07:23:41 +00:00
<!-- Automatically insert exposed configuration options here -->
2020-12-13 22:32:55 +00:00
## Other available fields
2020-04-07 07:23:41 +00:00
2022-01-11 15:25:14 +00:00
<!-- Autogenerate in https://github.com/renovatebot/renovate -->
2021-12-09 20:12:49 +00:00
<!-- Autogenerate end -->
2020-04-07 07:23:41 +00:00
<!-- Insert runtime fields here -->
2021-11-14 19:49:05 +00:00
## Additional Handlebars helpers
### stringToPrettyJSON
If you want to print pretty JSON with Handlebars you can use the built-in function `stringToPrettyJSON` like this:
`{{{stringToPrettyJSON myvar}}}`
2022-03-16 13:50:20 +00:00
In the example above `myvar` is a variable/field, that has valid JSON.
2022-01-06 15:24:42 +00:00
2022-01-11 10:50:48 +00:00
### encodeURIComponent
If you want to convert a string to a valid URI, use the built-in function `encodeURIComponent` like this:
`{{{encodeURIComponent baseDir}}}`
In the example above `baseDir` is the string you want to transform into a valid URI.
Read the [MDN Web Docs, encodeURIComponent() ](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/encodeURIComponent ) to learn more.
### replace
The `replace` helper replaces _all_ found strings with the replacement string.
If you want to replace some characters in a string, use the built-in function `replace` like this:
2022-01-25 18:27:45 +00:00
`{{{replace 'github.com' 'ghc' depName}}}`
2022-01-11 10:50:48 +00:00
In the example above all matches of `github.com` will be replaced by `ghc` in `depName` .
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.
2022-04-21 09:26:24 +00:00
### lowercase
The `lowercase` helper converts a given string to lower case.
`{{{ lowercase depName }}}`
2022-01-06 15:24:42 +00:00
### containsString
Returns `true` if a given string is a substring.
`{{#if (containsString depName 'python')}}Python{{else}}Other{{/if}}`
### and
Returns `true` only if all expressions are `true` .
`{{#if (and isMajor hasReleaseNotes)}}Backwards Incompatible release! Check out the Release notes.{{/if}}`
In the example above, it will only show a text if `isMajor=true` and `hasReleaseNotes=true` .
### or
Returns `true` if at least one expression is `true` .
`{{#if (or isPatch isSingleVersion}}Small update, safer to merge and release.{{else}}Check out the changelog for all versions before merging!{{/if}}`