98f5ae00fc
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.
21 lines
694 B
JavaScript
21 lines
694 B
JavaScript
var debug = require('ghost-ignition').debug('channels:render-post'),
|
|
formatResponse = require('./format-response'),
|
|
renderer = require('./renderer');
|
|
/*
|
|
* Sets the response context around an entry (post or page)
|
|
* and renders it with the correct template.
|
|
* Used by post preview and entry methods.
|
|
* Returns a function that takes the entry to be rendered.
|
|
*/
|
|
module.exports = function renderEntry(req, res) {
|
|
debug('renderEntry called');
|
|
return function renderEntry(entry) {
|
|
// Renderer begin
|
|
// Format data 2 - 1 is in preview/entry
|
|
var data = formatResponse.entry(entry);
|
|
|
|
// Render Call
|
|
return renderer(req, res, data);
|
|
};
|
|
};
|