atom-preview icon indicating copy to clipboard operation
atom-preview copied to clipboard

JSON Editor for Templating Languages that require context data input

Open Glavin001 opened this issue 10 years ago • 4 comments

Use JSON editor like: http://www.jsoneditoronline.org/

Glavin001 avatar Jul 30 '14 21:07 Glavin001

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.

Glavin001 avatar Jul 30 '14 21:07 Glavin001

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?

nmaggioni avatar Mar 13 '16 13:03 nmaggioni

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.

Glavin001 avatar Mar 13 '16 14:03 Glavin001

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!

nmaggioni avatar Mar 13 '16 15:03 nmaggioni