Widgets refactor (#5817)

* widgets refactor

render widgets server side
widgets can use all the data the template can use

* fix tests
This commit is contained in:
Barış Soner Uşaklı
2017-07-10 12:54:45 -04:00
committed by GitHub
parent 65329b9bd7
commit 923bd86662
10 changed files with 135 additions and 130 deletions

View File

@@ -7,6 +7,7 @@ var winston = require('winston');
var plugins = require('../plugins');
var translator = require('../translator');
var widgets = require('../widgets');
module.exports = function (middleware) {
middleware.processRender = function (req, res, next) {
@@ -49,6 +50,17 @@ module.exports = function (middleware) {
function (data, next) {
options = data.templateData;
widgets.render(req.uid, {
template: template + '.tpl',
url: options.url,
templateData: options,
req: req,
res: res,
}, next);
},
function (data, next) {
options.widgets = data;
res.locals.template = template;
options._locals = undefined;