forked from RandomEtc/ejs-locals
-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fixing #10 with app.set('views') being an array
- Loading branch information
1 parent
fdc74be
commit 4cbcb9b
Showing
5 changed files
with
68 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Views Array</h1> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
var express = require('express') | ||
, request = require('./support/http') | ||
, engine = require('../') | ||
, ejs = require('ejs') | ||
|
||
var app = express(); | ||
app.set('views',[__dirname + '/fixtures', __dirname + '/fixtures/thing']); | ||
app.engine('ejs', engine); | ||
|
||
// this is not the default behavior, but you can set this | ||
// if you want to load `layout.ejs` as the default layout | ||
// (this was the default in Express 2.0 so it's handy for | ||
// quick ports and upgrades) | ||
app.locals._layoutFile = true; | ||
|
||
app.get('/views-array',function(req,res,next){ | ||
res.render('index.ejs',{_layoutFile:false}) | ||
}) | ||
|
||
app.get('/views-array-thing',function(req,res,next){ | ||
res.render('views-array.ejs') | ||
}) | ||
|
||
describe('app with views array',function(){ | ||
|
||
describe('GET /views-array', function(){ | ||
it('should render index.ejs from /fixtures',function(done){ | ||
request(app) | ||
.get('/views-array') | ||
.end(function(res){ | ||
res.should.have.status(200); | ||
res.body.should.equal('<h1>Index</h1>'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
|
||
describe('GET /views-array-thing', function(){ | ||
it('should render views-array.ejs from /fixtures/thing',function(done){ | ||
request(app) | ||
.get('/views-array-thing') | ||
.end(function(res){ | ||
res.should.have.status(200); | ||
res.body.should.equal('<html><head><title>ejs-locals</title></head><body><h1>Views Array</h1></body></html>'); | ||
done(); | ||
}) | ||
}) | ||
}) | ||
|
||
}) |