removed layout-control example

no longer applies
This commit is contained in:
TJ Holowaychuk 2012-04-17 20:38:52 -07:00
parent cc69d50c60
commit e3f6faa350
6 changed files with 0 additions and 107 deletions

View File

@ -1,52 +0,0 @@
/**
* Module dependencies.
*/
var express = require('../../lib/express')
, url = require('url');
var app = express.createServer();
app.set('views', __dirname + '/views');
// map .html to ejs module
app.register('html', require('ejs'));
app.set('view engine', 'html');
// set default layout, usually "layout"
app.locals.layout = 'layouts/default';
app.use(function(req, res, next){
// expose the current path as a view local
res.locals.path = url.parse(req.url).pathname;
// assign content str for section
res.locals.contentFor = function(section, str){
res.locals[section] = str;
};
next();
});
app.get('/', function(req, res){
res.render('page');
});
app.get('/alternate', function(req, res){
res.render('page', { layout: 'layouts/alternate' });
});
app.get('/alternate2', function(req, res){
res.render('page2');
});
app.get('/defined-in-view', 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');
});
app.listen(3000);
console.log('Express app started on port 3000');

View File

@ -1 +0,0 @@
<p>Moar sidebar here</p>

View File

@ -1,26 +0,0 @@
<html>
<title>Alternate</title>
<style>
body {
padding: 50px;
font: 14px "helvetica neue", helvetica, sans-serif;
color: #333;
}
#sidebar {
float: left;
width: 150px;
}
#content {
float: left;
}
</style>
<body>
<h1>Alternate Layout</h1>
<div id="sidebar">
<%- sidebar %>
</div>
<div id="content">
<%- body %>
</div>
</body>
</html>

View File

@ -1,16 +0,0 @@
<html>
<head>
<title>Default</title>
<style>
body {
padding: 50px;
font: 14px "helvetica neue", helvetica, sans-serif;
color: #333;
}
</style>
</head>
<body>
<h1>Default Layout</h1>
<%- body %>
</body>
</html>

View File

@ -1,8 +0,0 @@
<h1>Page</h1>
<% if (path == '/alternate') { %>
<% contentFor('sidebar', partial('alternate-sidebar')) %>
<p>Click <a href="/">here</a> to view the default layout.</p>
<p>Click <a href="/alternate2">here</a> to view another alternate page.</p>
<% } else { %>
<p>Click <a href="/alternate">here</a> to view the alternate layout.</p>
<% } %>

View File

@ -1,4 +0,0 @@
<% layout('layouts/alternate') %>
<% contentFor('sidebar', '<p>Another sidebar here</p>') %>
<h1>Page</h1>
<p>Click <a href="/">here</a> to view the default layout.</p>