con2 / emrichen

A Template engine for YAML & JSON
MIT License
107 stars 11 forks source link

Allow emitting multi-document YAML files #32

Closed akx closed 5 years ago

akx commented 5 years ago

This PR adds as_documents: bool to the Loop tag. It only has an effect at the top level of a template.

Refs #31.

Example (from the test):

!Loop
  over: !Var domain_names
  as: item
  as_documents: true
  template:
    name: !Var item

is emitted as

name: hernekeit.to
---
name: vii.na
---
name: teli.ne
---
name: johann.es

whereas without the flag, it's emitted as a single document

- name: hernekeit.to
- name: vii.na
- name: teli.ne
- name: johann.es
hjanuschka commented 5 years ago

this is awesome, chances we can get this merged? i am the one, left not using helm, and built a large production setup using emrichen 👍 - and this change would reduce my template overhead ALOT!

japsu commented 5 years ago

@akx unable to review currently due to being in outer space 🚀 please merge without review at your leisure. Looked over the syntax, was ok to me. Does it error if as_documents: true is rendered anyw else than top level?

On Thu, 4 Jul 2019 at 11.39, Helmut Januschka notifications@github.com wrote:

this is awesome, chances we can get this merged? i am the one, left not using helm, and built a large production setup using emrichen 👍 - and this change would reduce my template overhead ALOT!

— You are receiving this because your review was requested. Reply to this email directly, view it on GitHub https://github.com/con2/emrichen/pull/32?email_source=notifications&email_token=AAA2WVJEKOSAM3GXMRZB3H3P5WZNPA5CNFSM4H5UVF52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODZGX7HI#issuecomment-508395421, or mute the thread https://github.com/notifications/unsubscribe-auth/AAA2WVJZM4FVSCBUNFR4FHTP5WZNPANCNFSM4H5UVF5Q .

-- Santtu Pajukanta

akx commented 5 years ago

Does it error if as_documents: true is rendered anyw else than top level?

No – it just has no effect. I don't think we have an easy way to figure out what level we're enriching at.

hjanuschka commented 5 years ago

this change lead to (with a first quick refactor): Bildschirmfoto 2019-07-04 um 12 33 53

thank you folks! (less code is best code)