mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Update express-hbs to 0.8.4
fixes #4364, refs #4439, refs #4799 - Update express-hbs to 0.8.5 - Use preventIndent option onCompile - Update registerAsyncHelper to support passing through options when needed
This commit is contained in:
parent
6bb073cf0e
commit
4b05585631
5 changed files with 21 additions and 7 deletions
|
@ -47,10 +47,15 @@ coreHelpers.helperMissing = function (arg) {
|
|||
|
||||
// Register an async handlebars helper for a given handlebars instance
|
||||
function registerAsyncHelper(hbs, name, fn) {
|
||||
hbs.registerAsyncHelper(name, function (options, cb) {
|
||||
// Wrap the function passed in with a when.resolve so it can
|
||||
// return either a promise or a value
|
||||
Promise.resolve(fn.call(this, options)).then(function (result) {
|
||||
hbs.registerAsyncHelper(name, function (context, options, cb) {
|
||||
// Handle the case where we only get context and cb
|
||||
if (!cb) {
|
||||
cb = options;
|
||||
options = undefined;
|
||||
}
|
||||
|
||||
// Wrap the function passed in with a when.resolve so it can return either a promise or a value
|
||||
Promise.resolve(fn.call(this, context, options)).then(function (result) {
|
||||
cb(result);
|
||||
}).catch(function (err) {
|
||||
errors.logAndThrowError(err, 'registerAsyncThemeHelper: ' + name);
|
||||
|
|
|
@ -52,7 +52,12 @@ function activateTheme(activeTheme) {
|
|||
blogApp.cache = {};
|
||||
|
||||
// set view engine
|
||||
hbsOptions = {partialsDir: [config.paths.helperTemplates]};
|
||||
hbsOptions = {
|
||||
partialsDir: [config.paths.helperTemplates],
|
||||
onCompile: function (exhbs, source) {
|
||||
return exhbs.handlebars.compile(source, {preventIndent: true});
|
||||
}
|
||||
};
|
||||
|
||||
fs.stat(themePartials, function (err, stats) {
|
||||
// Check that the theme has a partials directory before trying to use it
|
||||
|
|
|
@ -18,7 +18,10 @@ describe('{{navigation}} helper', function () {
|
|||
|
||||
before(function (done) {
|
||||
utils.loadHelpers();
|
||||
hbs.express3({partialsDir: [utils.config.paths.helperTemplates]});
|
||||
hbs.express3({
|
||||
partialsDir: [utils.config.paths.helperTemplates]
|
||||
});
|
||||
|
||||
hbs.cachePartials(function () {
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -12,6 +12,7 @@ describe('{{pagination}} helper', function () {
|
|||
before(function (done) {
|
||||
utils.loadHelpers();
|
||||
hbs.express3({partialsDir: [utils.config.paths.helperTemplates]});
|
||||
|
||||
hbs.cachePartials(function () {
|
||||
done();
|
||||
});
|
||||
|
|
|
@ -43,7 +43,7 @@
|
|||
"connect-slashes": "1.3.0",
|
||||
"downsize": "0.0.8",
|
||||
"express": "4.12.0",
|
||||
"express-hbs": "0.7.11",
|
||||
"express-hbs": "0.8.4",
|
||||
"extract-zip": "1.0.3",
|
||||
"fs-extra": "0.13.0",
|
||||
"glob": "4.3.2",
|
||||
|
|
Loading…
Add table
Reference in a new issue