Skip to main content
Version: v4.5.0

render-templates


The Declarative Hook render-templates can be used to perform the conditional generation of files. By using this type of Declarative Hook, associated with a condition, it is possible to control whether or not a file will be generated according to a condition. See an example:

hooks:  
- type: render-templates
trigger: after-render
path: templates-java
condition:
variable: language
operator: "=="
value: java
- type: render-templates
trigger: after-render
path: templates-kotlin
condition:
variable: language
operator: "=="
value: kotlin

In the case above, when the language input is filled with the value java, it generates the files that are in the templates-java folder. If the input is filled with the value kotlin, it generates the files that are in the templates-kotlin folder.

Available Actions

trigger:

Field to set triggers when the file generation should occur.

before-input: It executes the hook before receiving the input parameters from the user.

trigger: before-input

before-render: Runs the hook before the Template generates or updates files in the project.

trigger: before-render

after-render: Runs the hook after the Template generates or updates files in the project.

trigger: after-render

condition:

Field that determine a condition to execute the Declarative Hook.

variable:
Variable used in the condition. The variable is defined by inputs and computed-inputs of a Template or Plugin. For more information, see the Inputs in .yaml files section.

operator:
Conditional operator used in operations between variable and value. The operators are:

OperatorDescription
"=="Validates if the values are equal.
"!="Validates if the values are different.
">"Validates if the variable is greater than the value.
"<"Validates if the variable is less than the value.
">="Validates if the variable is greater than or equal to the value.
"<="Validates if the variable is less than or equal to the value.
containsAnyValidates if the list variable type contains any of the values in value.
containsAllValidates that the list variable type contains all the values in value.
containsOnlyValidates if the list variable type contains all the values in value and has no other elements.

value:
Reference value for the operator to check the conditional.

Read More

Was this page helpful?