Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation: if-else semantics #5731

Open
salotz opened this issue Feb 14, 2024 · 3 comments
Open

Documentation: if-else semantics #5731

salotz opened this issue Feb 14, 2024 · 3 comments

Comments

@salotz
Copy link

salotz commented Feb 14, 2024

The description here is really incomplete in using the if/else templating.

For instance its not clear about how this actually gets expanded and the example only covers lists.

For instance it is really confusing that this doesn't work:

group:
  normal_key: 1
  $if: true
  $then:
    some_other_key: 0

or

group:
  - item1
  $if: true
  $then:
    - item2

When you actually must put in the map/list in all or nothing like:

group:
  $if: true
  $then:
    normal_key: 1
    some_other_key: 0
  $else:
    normal_key: 1

I don't like the duplication that occurs because of this (another issue perhaps) but would be good to at least have the current behavior documented and show some useful examples of the most common gotcha. Feel free to use these examples!

@twelvemo
Copy link
Collaborator

Thanks for filing this issue, we really care about documentation and are super happy about feedback there.

@stefreak
Copy link
Member

@salotz you can use the $merge and $concat operators to prevent duplication:

group:
  normal_key: 1
  $merge:
    $if: true
    $then:
      some_other_key: 0

and

group:
  - item1
  - $concat:
      $if: true
      $then:
        - item2

@salotz
Copy link
Author

salotz commented Feb 25, 2024

@stefreak I will look into those. I did discover them after the fact of writing this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants