update documentation about lambdas (#21241)

This commit is contained in:
martin-mfg 2025-05-09 05:00:53 +02:00 committed by GitHub
parent ecd5d253a8
commit b55ae3caa8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View File

@ -820,15 +820,21 @@ Many generators (*those extending DefaultCodegen*) come with a small set of lamb
- `lowercase` - Converts all of the characters in this fragment to lower case using the rules of the `ROOT` locale.
- `uppercase` - Converts all of the characters in this fragment to upper case using the rules of the `ROOT` locale.
- `snakecase` - Converts text in a fragment to snake case. For example `once upon a time` to `once_upon_a_time`.
- `titlecase` - Converts text in a fragment to title case. For example `once upon a time` to `Once Upon A Time`.
- `kebabcase` - Converts text in a fragment to snake case. For example `Once Upon A Time` to `once-upon-a-time`.
- `pascalcase` - Converts text in a fragment to snake case. For example `once upon a time` to `OnceUponATime`.
- `camelcase` - Converts text in a fragment to camelCase. For example `Input-text` to `inputText`.
- `uncamelize` - Converts text in a fragment from camelCase or PascalCase to a string of words separated by whitespaces. For example `inputText` to `Input Text`.
- `forwardslash` - Replaces all occurrences of `\/`, `\` and `//` in a fragment by `/`.
- `backslash` - Replaces all occurrences `/` in a fragment by `\`.
- `doublequote` - Prepends `"` to the beginning and appends `"` to the end of a fragment.
- `indented` - Prepends 4 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_8` - Prepends 8 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_12` - Prepends 12 spaces indention from second line of a fragment on. First line will be indented by Mustache.
- `indented_16` -Prepends 16 spaces indention from second line of a fragment on. First line will be indented by Mustache.
Lambda is invoked by `lambda.[lambda name]` expression. For example: `{{#lambda.lowercase}}FRAGMENT TO LOWERCASE{{/lambda.lowercase}}` to lower case text between `lambda.lowercase`.
Some generators provide additional lambdas. Lambda is invoked by `lambda.[lambda name]` expression. For example: `{{#lambda.lowercase}}FRAGMENT TO LOWERCASE{{/lambda.lowercase}}` to lower case text between `lambda.lowercase`.
## Extensions

View File

@ -404,6 +404,8 @@ public class DefaultCodegen implements CodegenConfig {
* If common lambdas are not desired, override addMustacheLambdas() method
* and return empty builder.
*
* Corresponding user documentation: docs/templating.md, section "Mustache Lambdas"
*
* @return preinitialized map with common lambdas
*/
protected ImmutableMap.Builder<String, Lambda> addMustacheLambdas() {