diff --git a/lib/schema.js b/lib/schema.js index f733e1e12..d6302645b 100755 --- a/lib/schema.js +++ b/lib/schema.js @@ -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(), @@ -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(), diff --git a/test/integration/response.js b/test/integration/response.js index c30411fc9..b8d678012 100755 --- a/test/integration/response.js +++ b/test/integration/response.js @@ -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:
\n

Hapi

\n
\n'); + done(); + }); + }); + it('returns response without layout', function (done) { var layoutServer = new Hapi.Server({ debug: false });