Skip to content

Commit

Permalink
fix: add dynamic variable example
Browse files Browse the repository at this point in the history
  • Loading branch information
wrussell1999 authored Oct 24, 2024
1 parent d87aa5c commit 63745d5
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions content/docs/04.workflow-components/04.variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,29 @@ Dynamic variables will be rendered thanks to the Pebble templating engine. Pebbl
Since 0.14, Variables are no longer rendered recursively. You can read more about this change and how to change this behaviour [here](../11.migration-guide/0.14.0/recursive-rendering.md).
::

## Dynamic Variables

If you want to have an expression inside of your variable, you will need to wrap it in `render` when you use it in a task.

For example, this variable will only display the current time in the log message when wrapped in `render`. Otherwise, the log message will just contain the expression as a string:

```yaml
id: dynamic_variable
namespace: company.team
variables:
time: "{{ now() }}"
tasks:
- id: log
type: io.kestra.plugin.core.log.Log
message: "{{ render(vars.time) }}"
```

::alert{type="info"}
You will need to wrap the variable expression in `render` every time you want to use it in a task.
::

## FAQ

### How do I escape a block in Pebble syntax to ensure that it won't be parsed?
Expand Down

0 comments on commit 63745d5

Please sign in to comment.