Skip to content

Commit 70acff6

Browse files
committed
doc conditional packages
1 parent 80f4809 commit 70acff6

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

content/components/packages.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,28 @@ switch:
166166
# ...
167167
```
168168

169+
{{< anchor "config-packages_conditional" >}}
170+
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 `!include` into a substitution variable instead of under `packages`:
174+
175+
```yaml
176+
# In config.yaml
177+
substitutions:
178+
left_garage_door: !include
179+
file: garage-door.yaml
180+
vars:
181+
door_name: Left
182+
183+
enable_extra_door: true
184+
185+
packages:
186+
extra_door: ${ left_garage_door if enable_extra_door else {} }
187+
```
188+
189+
The above utilizes a {{< docref "/components/substitutions#jinja-expressions" "Jinja expression" >}} to determine whether `left_garage_door` package is actually included. `enable_extra_door` can be set from the {{< docref "/components/substitutions#command-line-substitutions" "command line" >}} as well.
190+
169191
{{< anchor "config-packages_extend" >}}
170192

171193
## Extend

0 commit comments

Comments
 (0)