From 9d064985eb66f36f10d1fc79f553c51a776be08b Mon Sep 17 00:00:00 2001 From: Sean Fridman Date: Wed, 1 Apr 2015 19:04:07 -0400 Subject: Switch to Liquid templates --- app/node_modules/oktemplate/index.js | 12 ++++++++++-- app/node_modules/oktemplate/package.json | 3 ++- app/node_modules/okview/index.js | 4 +++- 3 files changed, 15 insertions(+), 4 deletions(-) (limited to 'app/node_modules') diff --git a/app/node_modules/oktemplate/index.js b/app/node_modules/oktemplate/index.js index 4aec98b..8a725de 100644 --- a/app/node_modules/oktemplate/index.js +++ b/app/node_modules/oktemplate/index.js @@ -1,7 +1,8 @@ var fs = require('fs'); var path = require('path'); var glob = require('glob'); -var hogan = require('hogan.js'); +var LiquidEngine = require('liquid-node').Engine; +var liquid = new LiquidEngine(); /** * Manages templates. Only supports Mustache currently/ @@ -29,7 +30,14 @@ OKTemplateRepo.prototype._populateCache = function _populateCache(cache) { files.forEach(function eachFile(file) { var name = path.basename(file, self._ext); var templateString = fs.readFileSync(file, {encoding: 'UTF8'}); - cache[name] = hogan.compile(templateString); + cache[name] = { + name: name, + templateString: templateString, + render: function(data) { + // TODO Not sure if this caches parsed templates behind the scenes? + return liquid.parseAndRender(templateString, data); + } + } }); } diff --git a/app/node_modules/oktemplate/package.json b/app/node_modules/oktemplate/package.json index c32e098..eacc986 100644 --- a/app/node_modules/oktemplate/package.json +++ b/app/node_modules/oktemplate/package.json @@ -9,7 +9,8 @@ "author": "OKFocus", "license": "None", "dependencies": { + "bluebird": "^2.9.21", "glob": "^5.0.3", - "hogan.js": "^3.0.2" + "liquid-node": "^2.5.0" } } diff --git a/app/node_modules/okview/index.js b/app/node_modules/okview/index.js index 341ebdd..a049901 100644 --- a/app/node_modules/okview/index.js +++ b/app/node_modules/okview/index.js @@ -34,7 +34,9 @@ OKView.prototype.middleware = function() { }; OKView.prototype.render = function(req, res, data) { - return res.send(this._template.render(data)); + this._template.render(data).then(function(html) { + res.send(html); + }, errorHandler(req, res, data)); }; /** -- cgit v1.2.3-70-g09d2