Skip to content

Commit eb893b8

Browse files
Document conditional package !include (#5536)
* doc conditional packages * formatting * Update content/components/packages.md Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com> --------- Co-authored-by: Jonathan Swoboda <154711427+swoboda1337@users.noreply.github.com>
1 parent c4a95e5 commit eb893b8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

content/components/packages.md

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,29 @@ switch:
168168
# ...
169169
```
170170

171+
## Conditionally including a package
172+
173+
You can include a package based on a condition, or choose a package dinamically by loading your package with
174+
`!include` into a substitution variable instead of under `packages`:
175+
176+
```yaml
177+
# In config.yaml
178+
substitutions:
179+
left_garage_door: !include
180+
file: garage-door.yaml
181+
vars:
182+
door_name: Left
183+
184+
enable_extra_door: true
185+
186+
packages:
187+
extra_door: ${ left_garage_door if enable_extra_door else {} }
188+
```
189+
190+
The above utilizes a [Jinja expression](/components/substitutions#jinja-expressions) to determine whether
191+
`left_garage_door` package is actually included. `enable_extra_door` can be set from the
192+
[command line](/components/substitutions#command-line-substitutions) as well.
193+
171194
{{< anchor "config-packages_extend" >}}
172195

173196
## Extend

0 commit comments

Comments
 (0)