Ghost/core/server/controllers/frontend/render-channel.js
Hannah Wolfe 98f5ae00fc
Introduced renderer to DRY up controllers (#9235)
refs #5091, #9192

- Renderer figures out templates, contexts, and does a render call
- Templating is now handled with a single function
- Context call is made in the renderer

Note:  to make this work, all controllers now define a little bit of config, currently stored in res._route. (That's a totally temporary location, as is res._template... when a sensible naming convention reveals itself I'll get rid of the weird _). This exposes a type and for custom routes a template name & default.
2017-11-10 12:44:29 +00:00

17 lines
514 B
JavaScript

var debug = require('ghost-ignition').debug('channels:render'),
formatResponse = require('./format-response'),
renderer = require('./renderer');
module.exports = function renderChannel(req, res) {
debug('renderChannel called');
return function renderChannel(result) {
// Renderer begin
// Format data 2
// Do final data formatting and then render
var data = formatResponse.channel(result);
// Render Call
return renderer(req, res, data);
};
};