Skip to content

Support for YAML list syntax in loops #194

@bobbygryzynger

Description

@bobbygryzynger

Thanks for your presentation at KubeCon. I'm interested in how yamlscript could function as a templating engine on top of YAML.

While playing around with some examples with this in mind, I found the following behavior surprising.

Given the following program:

$ cat <<YS | ys -Ys -
!yamlscript/v0/data
foo:
  :each i (1 .. 3):
    i
YS

The following is produced:

foo:
- 1
- 2
- 3

When considering ys as a templating engine for YAML, support for the following syntax feels more natural:

$ cat <<YS | ys -Ys -
!yamlscript/v0/data
foo:
  :each i (1 .. 3):
    - i
YS

Here, there is an explicit list syntax rather than the list syntax output being implicit. However, a program in this form results in

Compile error: Sequences (block and flow) not allowed in code mode

Any chance you would support this more explicit syntax? This support would likely feel more familiar to helm users currently leveraging go templates.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions