Comparing version 1.1.0 to 1.2.0
@@ -183,3 +183,15 @@ "use strict"; | ||
*/ | ||
ajs.renderFile = function (path, opts, callback) { | ||
ajs.renderFile = function (path, data, opts, callback) { | ||
if (typeof data === "function") { | ||
callback = data; | ||
opts = {}; | ||
} else if (typeof opts === "function") { | ||
callback = opts; | ||
opts = {}; | ||
} | ||
opts = opts || {}; | ||
opts.locals = data; | ||
ajs.compileFile(path, opts, function (err, template) { | ||
@@ -193,2 +205,5 @@ if (err) { | ||
// Alias for express rendering | ||
ajs.__express = ajs.renderFile; | ||
/** | ||
@@ -195,0 +210,0 @@ * compileFile |
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "1.1.0", | ||
"version": "1.2.0", | ||
"author": "Ionică Bizău <bizauionica@gmail.com> (http://ionicabizau.net)", | ||
@@ -17,0 +17,0 @@ "contributors": [ |
@@ -27,2 +27,10 @@ "use strict"; | ||
}); | ||
t.should("render " + name + " templates (renderFile)", function (cb) { | ||
ajs.renderFile(files.inputAjs.path, require(files.inputJs.path), function (err, data) { | ||
err && console.log(err.stack); | ||
t.expect(err).toBe(null); | ||
t.expect(data).toBe(readFile(files.outputHtml.path)); | ||
cb(); | ||
}); | ||
}); | ||
}); | ||
@@ -29,0 +37,0 @@ |
117101
2752
12