-
-
Notifications
You must be signed in to change notification settings - Fork 10
Open
Description
Hello,
I am trying to generate some github config files with Elixir. To do so I use a YAML template (too keep newlines and comments), but I have to inject bits of data inside.
For now I use JSON:
jobs:
verify:
runs-on: ubuntu-latest
strategy:
matrix:
elixir: <%= json @matrix_elixir %>
otp: <%= json @matrix_otp %>
exclude: <%= json @matrix_exclude %>
To have better output capabilities, would you like to consider:
-
Allowing a fun/1 to be given as sort maps, in addition to boolean values. That function would return a term that would be used with
Enum.sort_by/2
. For instance:# version first, then jobs, then sort by key sorter = fn {:version, _} -> {0, 1} {:jobs, _} -> {0, 2} {k, _} -> {1, k} end Ymlr.document!(data, sort_maps: sorter)
-
Provide a function to encode a document without the
---
and starting at some arbitrary indentation level:# version first, then jobs, then sort by key def yaml(data, indent) do Ymlr.value!(data, start_indent: indent) end
jobs: verify: runs-on: ubuntu-latest strategy: matrix: elixir: <%= yaml @matrix_elixir, 5 %> otp: <%= yaml @matrix_otp, 5 %> exclude: <%= yaml @matrix_exclude, 5 %>
What do you think about that?
Metadata
Metadata
Assignees
Labels
No labels