terraform icon indicating copy to clipboard operation
terraform copied to clipboard

Alternatively accept `_data.js` for metadata instead of plain JSON?

Open sgoumaz opened this issue 11 years ago • 5 comments

Originally: https://github.com/sintaxi/harp/issues/103

This gist works for me (no edge case checks done though, that's for tests).

sgoumaz avatar Oct 02 '13 12:10 sgoumaz

You have peaked my curiosity, but it still isn't clear to me how one would use this. Can you give me an example of what a typical data.js might look like?

sintaxi avatar Oct 02 '13 18:10 sintaxi

Sure, I updated the gist with a _data.js. For such a simple case, the only differences with a _data.json are the module.exports = wrapping and the require() loading stuff from another file (which is what I want).

sgoumaz avatar Oct 02 '13 19:10 sgoumaz

Just in case, FYI I adjusted the gist code with those fixes:

  1. live updates to _data files weren't picked because of require() caching
  2. commented out obsolete line in catch block

sgoumaz avatar Oct 04 '13 15:10 sgoumaz

Just in case anybody would still like to know of use cases for this, there is the fact helper functions could be placed in _data.js. Also, if .coffee was also supported, it would allow a much nicer format for writing it.

jamesknelson avatar Feb 16 '14 02:02 jamesknelson

Did this ever go anywhere?

I've run into a similar use case (using harp) that would be covered by being able to include JS functions via a _data.js (vs _data.json).

Also, I'd be a fan of allowing .coffee extensions as well though .js itself would be fine.

sehrope avatar Jan 05 '15 19:01 sehrope