diff --git a/lib/views.js b/lib/views.js index 298a311b9..652b87a21 100755 --- a/lib/views.js +++ b/lib/views.js @@ -347,7 +347,7 @@ exports.handler = function (route, viewFilePath) { query: request.query }; - reply.view(viewFilePath, context); + reply.view(viewFilePath, request.route.bind || context); }; }; diff --git a/test/unit/views.js b/test/unit/views.js index d971f4b2b..eb8bb1458 100755 --- a/test/unit/views.js +++ b/test/unit/views.js @@ -272,5 +272,26 @@ describe('Views', function () { done(); }); }); + + it('handles bind context', function (done) { + + var options = { + views: { + engines: { 'jade': 'jade' }, + path: viewsPath + } + }; + + var server = new Hapi.Server(options); + + server.route({ method: 'GET', path: '/', handler: {view: 'valid/index'}, config: {bind: {message: 'heyloo'}}}); + server.inject({ + method: 'GET', + url: '/' + }, function (res) { + expect(res.result).to.contain('heyloo'); + done(); + }); + }); }); });