Closed djMax closed 4 years ago
No. Did you try it? Indentation does not matter as Emrichen does not operate on the file-based representation of YAML (where indentation matters) but rather on the deserialized representation of it, which consists of Python dicts, lists and other basic data types.
So what your YAML snippet says to Emrichen is to parse the ./configs/card1.yaml
template and put whatever was inside it in a dict under the key collections
.
Looking at an example like this:
(venv3-emrichen) japsu@Korok:~/Temp$ cat foo.in.yaml
collections:
!Include bar.in.yaml
(venv3-emrichen) japsu@Korok:~/Temp$ cat bar.in.yaml
- foo
- bar
(venv3-emrichen) japsu@Korok:~/Temp$ emrichen foo.in.yaml
collections:
- foo
- bar
In the output of emrichen
the list ["foo", "bar"]
is indeed not indented. But this is perfectly legal in YAML: lists need not be indented further. Or you could think of the contents of the list being indented but the bullet -
having a hanging indent.
We use a library called pyaml
to output YAML. Not indenting the contents of a list further, as allowed by YAML, is a choice made by the authors of pyaml
. Making this customizable is not on the Emrichen roadmap as usually the output of Emrichen is intended for the consumption of computers and not people. Using pyaml
instead of PyYAML
for output is already a concession towards human-readability - pyaml
produces somewhat more pleasant output than PyYAML
.
Should indent each line of card1.yaml by 2, but it doesn't, which makes invalid YAML out of two valid YAMLs, right?