coolony / kiwi

Simple yet powerful asynchronous JavaScript template engine based on jQuery Template syntax, usable server-side or client-side.
MIT License
41 stars 6 forks source link

Readme.md: Template from disk example causes undef error #24

Closed spacez320 closed 6 years ago

spacez320 commented 11 years ago

If you try to use the code specified in the Usage > Loading a template from disk section, it fails with a Cannot call method 'render' of undefined message on node 0.8.18.

It seems that trying to run a method on a variable being defined in this case fails, and the template must be instantiated by kiwi beforehand, as such:

// proposed fix
var template = new kiwi.Template();
template.loadFile('template.kiwi', function onLoaded(err) {
  template.render({ name: "Kiwi" }, function onRendered(err, rendered) {
    console.log('Rendered template is: ' + rendered);
  });
});