Glavin001/atom-preview

JSON Editor for Templating Languages that require context data input

Glavin001 opened this issue · 4 comments

We should allow the user to have multiple contexts that link to different templates. Users could switch between many different files with various purposes, and allowing contexts to be attached to the relevant files will be great for providing the seamless experience Preview users are accustomed to.

Couldn't a JSON file with the same name in the same folder get the job done?
For example: in order to supply the dummy data necessary to render index.jade, a file named index.json (or even index.jade.json, to avoid conflicts with other files) could be created in the same folder as index.jade; it would contain an object with all the needed dummy content.

Is this viable?

This is a very interesting ideal. I like the format of index.jade (template) -> index.jade.json (context), since it means a quick and straight forward lookup for a file with path <original_file_path>.json.
The extension could also be customizable, such that it could be <original_file_path>.context with custom extension .context.

Here is an example for Jade: http://jade-lang.com/demo/
It renders a template using whatever you define in the top rightmost box as context.

+1 for the customizable extension as well!