Skip to content

Commit

Permalink
docs(readme): Add sequence and map examples
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Jul 29, 2024
1 parent e51cb1a commit dba8587
Showing 1 changed file with 44 additions and 18 deletions.
62 changes: 44 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ The above produces `stable-alpine`
### Tags

By default, templated values are not explicitly quoted. This can cause
problems with some tools that require specific types. If you require a
problems with tools that require specific types. If you require a
specific type for a field, you can add a tag to the template prefix.

Supported tags:
Expand All @@ -272,20 +272,46 @@ Supported tags:
- `#yampl:seq`
- `#yampl:map`

For example, the following could be interpreted as either a string or an int:

```shell
$ cat example.yaml
num: #yampl {{ .num }}
$ yampl example.yaml -v num=2009
num: 2009 #yampl {{ .num }}
```

If this field must be a string, you could add the `str` tag:

```shell
$ cat example.yaml
num: #yampl:str {{ .num }}
$ yampl example.yaml -v num=2009
num: "2009" #yampl:str {{ .num }}
```
#### Examples

1. String

The following could be interpreted as either a string or an int:

```shell
$ cat example.yaml
num: #yampl {{ .num }}
$ yampl example.yaml -v num=2009
num: 2009 #yampl {{ .num }}
```

If this field must be a string, you could add the `str` tag:

```shell
$ cat example.yaml
num: #yampl:str {{ .num }}
$ yampl example.yaml -v num=2009
num: "2009" #yampl:str {{ .num }}
```

2. Sequence

```shell
$ cat example.yaml
seq: #yampl:seq {{ .seq }}
$ yampl example.yaml -v seq='[a, b, c]'
seq: #yampl {{ .seq }}
- a
- b
- c
```

3. Map

```shell
$ cat example.yaml
map: #yampl:map {{ .map }}
$ yampl example.yaml -v map='{message: hello world}'
map: #yampl {{ .map }}
message: hello world
```

0 comments on commit dba8587

Please sign in to comment.