Skip to content

Commit

Permalink
docs: mention handlebars escaping
Browse files Browse the repository at this point in the history
  • Loading branch information
rarkins committed Jul 3, 2020
1 parent 53c99a7 commit 4ff6fd5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion docs/usage/configuration-options.md
Expand Up @@ -1294,7 +1294,7 @@ Users can define custom managers for cases such as:

The custom manager concept is based on using Regular Expression named capture groups. For the fields `datasource`, `depName` and `currentValue`, it's mandatory to have either a named capture group matching them (e.g. `(?<depName>.*)`) or to configure it's corresponding template (e.g. `depNameTemplate`). It's not recommended to do both, due to the potential for confusion. It is recommended to also include `versioning` however if it is missing then it will default to `semver`.

For more details and examples, see the documentation page the for the regex manager [here](/modules/manager/regex/).
For more details and examples, see the documentation page the for the regex manager [here](/modules/manager/regex/). For template fields, use the triple brace `{{{ }}}` notation to avoid `handlebars` escaping any special characters.

### matchStrings

Expand Down
2 changes: 1 addition & 1 deletion lib/datasource/repology/readme.md
Expand Up @@ -20,7 +20,7 @@ A real world example for this specific datasource would be maintaining system pa
"matchStrings": [
"#\\s*renovate:\\s*datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}"
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
}
]
}
Expand Down
4 changes: 2 additions & 2 deletions lib/manager/regex/readme.md
Expand Up @@ -84,7 +84,7 @@ The above (obviously not a complete `Dockerfile`, but abbreviated for this examp
"matchStrings": [
"datasource=(?<datasource>.*?) depName=(?<depName>.*?)( versioning=(?<versioning>.*?))?\\sENV .*?_VERSION=(?<currentValue>.*)\\s"
],
"versioningTemplate": "{{#if versioning}}{{versioning}}{{else}}semver{{/if}}"
"versioningTemplate": "{{#if versioning}}{{{versioning}}}{{else}}semver{{/if}}"
},
{
"fileMatch": ["^Dockerfile$"],
Expand All @@ -97,6 +97,6 @@ The above (obviously not a complete `Dockerfile`, but abbreviated for this examp
}
```

In the above the `versioningTemplate` is not actually necessary because Renovate already defaults to `semver` versioning, but it has been included to help illustrate why we call these fields _templates_. They are named this way because they are compiled using `handlebars` and so can be composed from values you collect in named capture groups.
In the above the `versioningTemplate` is not actually necessary because Renovate already defaults to `semver` versioning, but it has been included to help illustrate why we call these fields _templates_. They are named this way because they are compiled using `handlebars` and so can be composed from values you collect in named capture groups. You will usually want to use the tripe brace `{{{ }}}` template (e.v. `{{{versioniong}}}` to be safe because `handlebars` escapes special characters by default with double braces.

By adding the comments to the `Dockerfile`, you can see that instead of four separate `regexManagers` being required, there is now only one - and the `Dockerfile` itself is now somewhat better documented too. The syntax we used there is completely arbitrary and you may choose your own instead if you prefer - just be sure to update your `matchStrings` regex.

0 comments on commit 4ff6fd5

Please sign in to comment.