Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #1 from lorrenbiffin/master

Added support for Express
  • Loading branch information...
commit 1d04e307fcc14de64f36297ef14a511bf801cf1a 2 parents 1ebdf3e + 52dd4d8
@skid authored
Showing with 26 additions and 2 deletions.
  1. +26 −2 index.js
View
28 index.js
@@ -95,5 +95,29 @@ function fromString( string ){
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);
+ }
+};
Please sign in to comment.
Something went wrong with that request. Please try again.