mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
abaf0461cf
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
25 lines
753 B
JavaScript
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);
|
|
};
|
|
};
|