How can I load ICanHaz.js templates using node.js?

I read in the ICanHaz.js documentation that I should download templates from a remote, for example,

$.getJSON('/myserver/templates.json', function (templates) { $.each(templates, function (template) { ich.addTemplate(template.name, template.template); }); }); 

I have no idea what the json template should look like, really appreciate the example ICanHaz.js json template.

thanks

+4
source share
1 answer

To save time debugging $ .each, two arguments to the callback function are required: an iterator and an actual object

 $.getJSON('/myserver/templates.json', function (templates) { $.each(templates, function (id, template) { ich.addTemplate(template.name, template.template); }); }); 

Of course, you must remember what you promise, as these templates are loaded in asynchronous mode.

+3
source

Source: https://habr.com/ru/post/1388642/


All Articles