forked from expressjs/express
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
66 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
|
||
// Expose modules in ./support for demo purposes | ||
require.paths.unshift(__dirname + '/../../support'); | ||
|
||
/** | ||
* Module dependencies. | ||
*/ | ||
|
||
var express = require('../../lib/express'); | ||
|
||
var app = express.createServer(); | ||
|
||
app.set('views', __dirname + '/views'); | ||
|
||
// set default layout, usually "layout" | ||
app.set('view options', { layout: 'layouts/default' }); | ||
|
||
// Set our default template engine to "jade" | ||
// which prevents the need for extensions | ||
// (although you can still mix and match) | ||
app.set('view engine', 'ejs'); | ||
|
||
app.get('/', function(req, res){ | ||
res.render('pages/default'); | ||
}); | ||
|
||
app.get('/alternate', function(req, res){ | ||
// note that we do not explicitly | ||
// state the layout here, the view does, | ||
// although we could do it here as well. | ||
res.render('pages/alternate'); | ||
}); | ||
|
||
app.listen(3000); | ||
console.log('Express app started on port 3000'); |
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,6 @@ | ||
<html> | ||
<body> | ||
<h1>Alternate Layout</h1> | ||
<%- body %> | ||
</body> | ||
</html> |
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,6 @@ | ||
<html> | ||
<body> | ||
<h1>Default Layout</h1> | ||
<%- body %> | ||
</body> | ||
</html> |
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,2 @@ | ||
<% locals.layout = 'layouts/alternate' %> | ||
<h1>Page</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<h1>Page</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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
- locals.layout = 'layouts/alternate' | ||
h1 My Page |
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 @@ | ||
#alternate= body |
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