mirror of
https://github.com/zebrajr/express.git
synced 2025-12-06 12:19:51 +01:00
removed layout-control example
no longer applies
This commit is contained in:
parent
cc69d50c60
commit
e3f6faa350
|
|
@ -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');
|
||||
|
|
@ -1 +0,0 @@
|
|||
<p>Moar sidebar here</p>
|
||||
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
|
|
@ -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>
|
||||
<% } %>
|
||||
|
|
@ -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>
|
||||
Loading…
Reference in New Issue
Block a user