You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/components/packages.md
+22Lines changed: 22 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -166,6 +166,28 @@ switch:
166
166
# ...
167
167
```
168
168
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.
0 commit comments