4 ms·
const thingies = ["a", "b"]; const thingToYaml = thing => yaml`- thing: ${thing}` const thingiesYaml = thingies.map(thingToYaml) const config =
by monkpit 4y ago
const thingies = ["a", "b"];
const thingToYaml = thing =>
yaml`- thing: ${thing}`
const thingiesYaml =
thingies.map(thingToYaml)
const config = yaml`
- foo
- bar
- baz
- thingies: ${thingiesYaml}
`;
It doesn’t have to be hard to read
- shhsshs 4y agoIn this example, why use YAML at all?... const thingies = ["a", "b"]; const config = [ "foo", "bar", "baz", { thingies: thingies.map(thing => ({ thing })), }, ] // config = ["foo", "bar", "baz", { "thingies": [{"thing": "a"}, {"thing": "b"}] }]
- zeroonetwothree 4y agoRight, it's not a great example since yaml is intentionally equivalent to JS objects.