From 257169e8c94ae3241c7efe8b32151aa1e47f563a Mon Sep 17 00:00:00 2001 From: Jacob Gable Date: Wed, 30 Oct 2013 21:05:24 -0500 Subject: [PATCH] Fix async helpers losing proper "this" context Fixes #1357 - Instead of calling the passed function directly, use .call(this, options) --- core/ghost.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/ghost.js b/core/ghost.js index 6471924a2f..7aa64901c8 100644 --- a/core/ghost.js +++ b/core/ghost.js @@ -287,7 +287,7 @@ Ghost.prototype.registerAsyncThemeHelper = function (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 - when.resolve(fn(options)).then(function (result) { + when.resolve(fn.call(this, options)).then(function (result) { cb(result); }).otherwise(function (err) { errors.logAndThrowError(err, "registerAsyncThemeHelper: " + name);