|
|
|
|
|
by renlo
1202 days ago
|
|
They've allowed "styled-components" to work though, which is pretty nice. I always thought of them as providing a way to parse DSLs directly in your code. For example, a fictional way to generate some config could look like this (using tagged templates): const thingies = ["a", "b"];
const config = yaml`
- foo
- bar
- baz
- thingies: ${thingies.map(thing => yaml`- thing: ${thing}`)}
`;
// config = ["foo", "bar", "baz", { "thingies": [{"thing": "a"}, {"thing": "b"}] }]
At a company I worked at people were generating YAML using Jinja templates, but tagged templates to me would be a better approach. Is it hard to read? It can be, but compared to the alternatives it's not too bad. |
|