Ghost/core/server/controllers/frontend/render-channel.js
Hannah Wolfe abaf0461cf Highlighted routes, controllers & renderers
refs #5091, refs #9192

- There are several theme template "renderers" all over the codebase
- Some are in apps, and were called "controllers"
- One is in error handling
- All of them now have comments marking out how they share logic/steps
- Other comments describe routes & controllers where they live
2017-11-08 09:45:12 +00:00

25 lines
753 B
JavaScript

var debug = require('ghost-ignition').debug('channels:render'),
formatResponse = require('./format-response'),
setResponseContext = require('./context'),
templates = require('./templates');
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
result = formatResponse.channel(result);
// Context
setResponseContext(req, res);
// Template
res.template = templates.channel(res.locals.channel);
// Render Call
debug('Rendering view: ' + res.template);
res.render(res.template, result);
};
};