Skip to content

Commit

Permalink
Merge pull request #1380 from evilpacket/allow_bind_context
Browse files Browse the repository at this point in the history
Allow bind context for view handler
  • Loading branch information
Eran Hammer committed Feb 10, 2014
2 parents 1c5d485 + c290648 commit b51594a
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ exports.handler = function (route, viewFilePath) {
query: request.query
};

reply.view(viewFilePath, context);
reply.view(viewFilePath, request.route.bind || context);
};
};

Expand Down
21 changes: 21 additions & 0 deletions test/unit/views.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});
});
});
});

0 comments on commit b51594a

Please sign in to comment.