mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 16:01:40 +03:00
23 lines
771 B
JavaScript
23 lines
771 B
JavaScript
|
var debug = require('ghost-ignition').debug('channels:render-post'),
|
||
|
templates = require('./templates'),
|
||
|
formatResponse = require('./format-response'),
|
||
|
setResponseContext = require('./context');
|
||
|
/*
|
||
|
* Sets the response context around a post and renders it
|
||
|
* with the current theme's post view. Used by post preview
|
||
|
* and single post methods.
|
||
|
* Returns a function that takes the post to be rendered.
|
||
|
*/
|
||
|
|
||
|
module.exports = function renderPost(req, res) {
|
||
|
debug('renderPost called');
|
||
|
return function renderPost(post) {
|
||
|
var view = templates.single(post),
|
||
|
response = formatResponse.single(post);
|
||
|
|
||
|
setResponseContext(req, res, response);
|
||
|
debug('Rendering view: ' + view);
|
||
|
res.render(view, response);
|
||
|
};
|
||
|
};
|