vadimdemedes / mustached

CLI tool to render Mustache templates with JSON as data input
MIT License
2 stars 0 forks source link

YAML #1

Open trans opened 8 years ago

trans commented 8 years ago

Would be great if it also supported YAML.

P.S. I was just about to write this very utility. Now I don't have to. Yeah!!!!

vadimdemedes commented 8 years ago

Yeah, I think it would! However, I'm very short on time and I'm trying to dedicate it to big projects, like AVA and Mongorito.

If you feel like doing a PR for it, that'd be great ;)

trans commented 8 years ago

I can probably do that. Shouldn't take long (assuming there are no complications). What do you want the interface to be? I'm thinking of using a simple heuristic to distinguish YAML vs JSON. Sound okay?

vadimdemedes commented 8 years ago

I'm thinking of using a simple heuristic to distinguish YAML vs JSON.

Sounds unstable to me and I feel it will cause bugs.

Here's how I would do it. In case of using stdin for reading template data, I'd introduce --yaml flag to indicate that the incoming data is YAML, not JSON. If a -f flag is used (filename is known), we could just check the file extension (.json or .yml or .yaml). To recap:

$ cat data.yaml | mustached --yaml -t hello.mustache
$ mustached -t hello.mustache -f data.yaml
trans commented 8 years ago

Okay.