-
Notifications
You must be signed in to change notification settings - Fork 27
getTemplate
miroshnikov edited this page Mar 27, 2015
·
1 revision
Whenever there is {include} or {extends} tag in a template, jSmart.prototype.getTemplate() method gets called, it receives the tag's file parameter as an argument. The method must return the template's text.
The default implementation of getTemplate() throws an exception. So, it is up to a jSmart user to override this method and provide template's text.
/* browser example */
jSmart.prototype.getTemplate = function(id) {
return document.getElementById(id).innerHTML;
}/* CommonJS example: */
var fs = require('fs');
jSmart.prototype.getTemplate = function(name) {
return fs.readFileSync('path/to/templates/'+name, 'utf8');
}