Skip to content
Myr

app.js

This file

Path

examples/layout-control/app.js

34 lines · 852 bytes · JavaScript

Last changed by

Merged pull request #645 from 8bitDesigner/patch-1.TJ Holowaychukbefore adoptionfc2bc13

History of this file

Take it

Merge branch 'feature/view-layout-control'Tj Holowaychukbefore adoption6a58c71

lines 1–16why, one step back
1// Expose modules in ./support for demo purposes
2require.paths.unshift(__dirname + '/../../support');34/**5 * Module dependencies.6 */78var express = require('../../lib/express');910var app = express.createServer();1112app.set('views', __dirname + '/views');1314// set default layout, usually "layout"15app.set('view options', { layout: 'layouts/default' });16

Merged pull request #645 from 8bitDesigner/patch-1.TJ Holowaychukbefore adoptionfc2bc13

line 17why, one step back
17// Set our default template engine to "ejs"

Merge branch 'feature/view-layout-control'Tj Holowaychukbefore adoption6a58c71

lines 18–34why, one step back
18// which prevents the need for extensions
19// (although you can still mix and match)20app.set('view engine', 'ejs');2122app.get('/', function(req, res){23 res.render('pages/default');24});2526app.get('/alternate', function(req, res){27 // note that we do not explicitly28 // state the layout here, the view does,29 // although we could do it here as well.30 res.render('pages/alternate');31});3233app.listen(3000);34console.log('Express app started on port 3000');