Skip to content

Commit

Permalink
Fix view layout schema definition. Closes hapijs#1335
Browse files Browse the repository at this point in the history
  • Loading branch information
Eran Hammer committed Dec 29, 2013
1 parent e0b215d commit 72405df
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/schema.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ internals.serverSchema = {
basePath: Joi.string(),
compileOptions: Joi.object(),
runtimeOptions: Joi.object(),
layout: Joi.boolean(),
layout: Joi.string().allow(false, true),
layoutKeyword: Joi.string(),
encoding: Joi.string(),
isCached: Joi.boolean(),
Expand Down Expand Up @@ -266,7 +266,7 @@ internals.viewSchema = {
basePath: Joi.string().allow(''),
compileOptions: Joi.object(),
runtimeOptions: Joi.object(),
layout: Joi.boolean(),
layout: Joi.string().allow(false, true),
layoutKeyword: Joi.string(),
encoding: Joi.string(),
isCached: Joi.boolean(),
Expand Down
25 changes: 25 additions & 0 deletions test/integration/response.js
Original file line number Diff line number Diff line change
Expand Up @@ -1799,6 +1799,31 @@ describe('Response', function () {
});
});

it('returns response with custom server layout', function (done) {

var layoutServer = new Hapi.Server({ debug: false });
layoutServer.views({
engines: { 'html': 'handlebars' },
path: __dirname + '/../unit/templates',
layout: 'otherLayout'
});

var handler = function (request, reply) {

return reply.view('valid/test', { title: 'test', message: 'Hapi' });
};

layoutServer.route({ method: 'GET', path: '/', handler: handler });

layoutServer.inject('/', function (res) {

expect(res.result).to.exist;
expect(res.statusCode).to.equal(200);
expect(res.result).to.equal('test:<div>\n <h1>Hapi</h1>\n</div>\n');
done();
});
});

it('returns response without layout', function (done) {

var layoutServer = new Hapi.Server({ debug: false });
Expand Down

0 comments on commit 72405df

Please sign in to comment.