mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-20 17:32:15 +03:00
bf0823c9a2
- This is the beginning of splitting up the theme service into: - Storage components used by the API (should be a server service) - Theme engine & rendering components used by the frontend (this new engine service) - The code to activate a theme which is shared code where the API & frontend need to communicate - This is needed because currently the frontend theme service is required and used by the API, creating tight coupling. - In my quest to truly separate the API and frontend, this is one of many battles that needs winning
28 lines
789 B
JavaScript
28 lines
789 B
JavaScript
const hbs = require('express-hbs');
|
|
const config = require('../../../shared/config');
|
|
const instance = hbs.create();
|
|
|
|
// @TODO think about a config option for this e.g. theme.devmode?
|
|
if (config.get('env') !== 'production') {
|
|
instance.handlebars.logger.level = 0;
|
|
}
|
|
|
|
instance.escapeExpression = instance.handlebars.Utils.escapeExpression;
|
|
|
|
instance.configure = function configure(partialsPath) {
|
|
const hbsOptions = {
|
|
partialsDir: [config.get('paths').helperTemplates],
|
|
onCompile: function onCompile(exhbs, source) {
|
|
return exhbs.handlebars.compile(source, {preventIndent: true});
|
|
}
|
|
};
|
|
|
|
if (partialsPath) {
|
|
hbsOptions.partialsDir.push(partialsPath);
|
|
}
|
|
|
|
return instance.express4(hbsOptions);
|
|
};
|
|
|
|
module.exports = instance;
|