mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-18 07:51:55 +03:00
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.
17 lines
474 B
JavaScript
17 lines
474 B
JavaScript
var debug = require('ghost-ignition').debug('renderer'),
|
|
setContext = require('./context'),
|
|
templates = require('./templates');
|
|
|
|
module.exports = function renderer(req, res, data) {
|
|
// Context
|
|
setContext(req, res, data);
|
|
|
|
// Template
|
|
templates.setTemplate(req, res, data);
|
|
|
|
// Render Call
|
|
debug('Rendering template: ' + res._template + ' for: ' + req.originalUrl);
|
|
debug('res.locals', res.locals);
|
|
res.render(res._template, data);
|
|
};
|