mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Including theme partials in a way that supports symbolically linked directories
closes #1937 - using fs.stat() instead of hasOwnProperty() to test for directory existence
This commit is contained in:
parent
c82d2eadba
commit
6437f343c1
1 changed files with 9 additions and 3 deletions
|
@ -10,6 +10,7 @@ var middleware = require('./middleware'),
|
||||||
slashes = require('connect-slashes'),
|
slashes = require('connect-slashes'),
|
||||||
errors = require('../errorHandling'),
|
errors = require('../errorHandling'),
|
||||||
api = require('../api'),
|
api = require('../api'),
|
||||||
|
fs = require('fs'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
hbs = require('express-hbs'),
|
hbs = require('express-hbs'),
|
||||||
config = require('../config'),
|
config = require('../config'),
|
||||||
|
@ -91,6 +92,7 @@ function initViews(req, res, next) {
|
||||||
// Helper for manageAdminAndTheme
|
// Helper for manageAdminAndTheme
|
||||||
function activateTheme(activeTheme) {
|
function activateTheme(activeTheme) {
|
||||||
var hbsOptions,
|
var hbsOptions,
|
||||||
|
themePartials = path.join(config.paths().themePath, activeTheme, 'partials'),
|
||||||
stackLocation = _.indexOf(expressServer.stack, _.find(expressServer.stack, function (stackItem) {
|
stackLocation = _.indexOf(expressServer.stack, _.find(expressServer.stack, function (stackItem) {
|
||||||
return stackItem.route === config.paths().subdir && stackItem.handle.name === 'settingEnabled';
|
return stackItem.route === config.paths().subdir && stackItem.handle.name === 'settingEnabled';
|
||||||
}));
|
}));
|
||||||
|
@ -106,10 +108,14 @@ function activateTheme(activeTheme) {
|
||||||
|
|
||||||
// set view engine
|
// set view engine
|
||||||
hbsOptions = { partialsDir: [ config.paths().helperTemplates ] };
|
hbsOptions = { partialsDir: [ config.paths().helperTemplates ] };
|
||||||
if (config.paths().availableThemes[activeTheme].hasOwnProperty('partials')) {
|
|
||||||
|
fs.stat(themePartials, function (err, stats) {
|
||||||
// Check that the theme has a partials directory before trying to use it
|
// Check that the theme has a partials directory before trying to use it
|
||||||
hbsOptions.partialsDir.push(path.join(config.paths().themePath, activeTheme, 'partials'));
|
if (!err && stats && stats.isDirectory()) {
|
||||||
}
|
hbsOptions.partialsDir.push(themePartials);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
expressServer.set('theme view engine', hbs.express3(hbsOptions));
|
expressServer.set('theme view engine', hbs.express3(hbsOptions));
|
||||||
|
|
||||||
// Update user error template
|
// Update user error template
|
||||||
|
|
Loading…
Add table
Reference in a new issue