Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.renderPartial = function(template, object){
var include = function(template, fallback){
if (!template) template = '';
while (true) try {
return require('promised-io/fs').read(exports.templatesDir + '/' + template, 'utf8');
} catch (x) {
if (!fallback || template === fallback)
return null;
template = fallback;
}
};
//template: request.nodeRequest.url.replace /\?.*$/, ''
var engine = require('ejs/ejs');
var str = include(template, template.substring(template.lastIndexOf('.')));
var html = engine.render(str, {
context: engine, // N.B. this will be 'this' in templates
locals: object, // variables available to the templates
cache: false, // TODO: optify
filename: template
});
return [html];
};