This commit is contained in:
harttle
2016-06-24 11:17:10 +08:00
parent e6cd6e4d46
commit aebf9812cb
5 changed files with 105 additions and 45 deletions
+19
View File
@@ -0,0 +1,19 @@
const Liquid = require('..');
module.exports = function() {
var engine = Liquid({
root: '/root/',
extname: '.html'
});
function express(filePath, options, callback) {
fs.readFile(filePath, function(err, content) {
if (err) return callback(new Error(err));
// this is an extremely simple template engine
var rendered = content.toString().replace('#title#', '<title>' + options.title + '</title>')
.replace('#message#', '<h1>' + options.message + '</h1>');
return callback(null, rendered);
});
}
return express;
};