Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added support for Express #1

Merged
merged 1 commit into from Jun 30, 2011
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 26 additions & 2 deletions index.js
Expand Up @@ -95,5 +95,29 @@ function fromString( string ){
return CACHE[hash] = createTemplate(string, hash); return CACHE[hash] = createTemplate(string, hash);
} }


exports.fromFile = fromFile;
exports.fromString = fromString; var nodet = require('node-t');

module.exports = {
fromFile: fromFile,
fromString: fromString,
compile: function (source, options, callback) {
self = this;
if (typeof source == 'string') {
return function(options) {
options.locals = options.locals || {};
options.partials = options.partials || {};
if (options.body) // for express.js > v1.0
options.locals.body = options.body;
var tmpl = fromString(source);
return tmpl.render(options.locals);
};
} else {
return source;
}
},
render: function (template, options) {
template = this.compile(template, options);
return template(options);
}
};