2017-08-15 12:29:27 +01:00
|
|
|
var debug = require('ghost-ignition').debug('channels:render'),
|
|
|
|
formatResponse = require('./format-response'),
|
2016-02-09 14:14:24 +00:00
|
|
|
setResponseContext = require('./context'),
|
2017-08-15 12:29:27 +01:00
|
|
|
templates = require('./templates');
|
2016-02-09 14:14:24 +00:00
|
|
|
|
2017-11-06 12:17:24 +00:00
|
|
|
module.exports = function renderChannel(req, res) {
|
2016-10-03 09:33:14 +01:00
|
|
|
debug('renderChannel called');
|
2017-11-06 12:17:24 +00:00
|
|
|
return function renderChannel(result) {
|
2017-11-05 12:45:43 +00:00
|
|
|
// Renderer begin
|
|
|
|
// Format data 2
|
|
|
|
// Do final data formatting and then render
|
2017-11-06 12:17:24 +00:00
|
|
|
result = formatResponse.channel(result);
|
2016-02-09 14:14:24 +00:00
|
|
|
|
2017-11-05 12:45:43 +00:00
|
|
|
// Context
|
2017-11-06 12:17:24 +00:00
|
|
|
setResponseContext(req, res);
|
2017-11-05 12:45:43 +00:00
|
|
|
|
|
|
|
// Template
|
|
|
|
res.template = templates.channel(res.locals.channel);
|
|
|
|
|
|
|
|
// Render Call
|
|
|
|
debug('Rendering view: ' + res.template);
|
|
|
|
res.render(res.template, result);
|
2017-11-06 12:17:24 +00:00
|
|
|
};
|
|
|
|
};
|