Skip to content
Snippets Groups Projects
Unverified Commit 2c087e86 authored by IKEDA Sho's avatar IKEDA Sho Committed by GitHub
Browse files

feat(template): add `lowercase` Handlebars helper (#15212)

parent 65b6697a
No related branches found
No related tags found
No related merge requests found
......@@ -58,6 +58,12 @@ In the example above all matches of `github.com` will be replaced by `ghc` in `d
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.
......
......@@ -74,4 +74,10 @@ describe('util/template/index', () => {
const output = template.compile(userTemplate, undefined);
expect(output).toMatchSnapshot();
});
it('lowercase', () => {
const userTemplate = "{{{ lowercase 'FOO'}}}";
const output = template.compile(userTemplate, undefined);
expect(output).toBe('foo');
});
});
......@@ -17,6 +17,8 @@ handlebars.registerHelper(
(context || '').replace(new RegExp(find, 'g'), replace) // TODO #12873
);
handlebars.registerHelper('lowercase', (str: string) => str.toLowerCase());
handlebars.registerHelper('containsString', (str, subStr, options) =>
str.includes(subStr)
);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment