Skip to content

Commit 8e0b661

Browse files
committed
harmonize syntax options in include and templates
Signed-off-by: Jimmy Tanagra <[email protected]>
1 parent 7458960 commit 8e0b661

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

configuration/yaml/include.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@ title: YAML Configuration - Include Files
88
`!include` inserts the referenced file or structure exactly at the position where the include appears.
99

1010
openHAB supports including external YAML files to facilitate modular, reusable, and maintainable configurations.
11-
This is especially useful for templating, creating device [packages](packages.md), or separating concerns across multiple files.
11+
This is especially useful for modular reuse, creating device [packages](packages.md), or separating concerns across multiple files.
1212

1313
[[toc]]
1414

1515
## Syntax Options
1616

17-
### Simple Syntax
17+
### Short Form
1818

1919
```yaml
2020
keyname: !include filename.inc.yaml
2121
```
2222
23-
Use this when no variable overrides are needed.
23+
Use this when you don’t need to explicitly pass any variables.
2424
25-
### Full Syntax
25+
### Long Form (supports variables)
2626
2727
```yaml
2828
# Block style (multi-line)
@@ -32,15 +32,16 @@ keyname: !include
3232
var1: value1
3333
var2: value2
3434

35-
# Or inline style (single-line)
35+
# Or flow style (single-line)
3636
keyname: !include { file: filename.inc.yaml, vars: { var1: value1, var2: value2 } }
3737
```
3838
39-
In the full syntax, the `vars` section is optional.
39+
The `vars:` mapping is layered on top of the file’s current variables to form the evaluation context.
40+
In the long form, the `vars:` section is optional.
4041

4142
::: tip Passing Existing Variables to Included Files
4243

43-
The `vars` section of an `!include` directive can contain literal values or references to **existing variables**.
44+
The `vars:` section of an `!include` directive can contain literal values or references to **existing variables**.
4445

4546
Example:
4647

configuration/yaml/templates.md

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,28 +49,34 @@ Therefore, a template may contain references to variables that do not yet exist;
4949

5050
:::
5151

52-
## Using `!insert`
52+
## Syntax Options
5353

5454
`!insert` expands a template at the point where it appears.
5555
It supports two forms:
5656

5757
### Short Form
5858

59-
Use when no variables need to be passed:
60-
6159
```yaml
6260
message: !insert simple_greeting
6361
```
6462

65-
### Long Form (with variables)
63+
Use this when you don’t need to explicitly pass any variables.
6664

67-
Use when the template requires parameters:
65+
### Long Form (supports variables)
6866

6967
```yaml
68+
# Block style (multi-line)
69+
message: !insert
70+
template: greeting
71+
vars:
72+
name: "Jimmy"
73+
74+
# Or flow style (single-line)
7075
message: !insert { template: greeting, vars: { name: "Jimmy" } }
7176
```
7277

7378
The `vars:` mapping is layered on top of the file’s current variables to form the evaluation context.
79+
In the long form, the `vars:` section is optional.
7480

7581
## How Template Evaluation Works
7682

0 commit comments

Comments
 (0)