Created
April 19, 2011 11:12
-
-
Save aseemk/927144 to your computer and use it in GitHub Desktop.
Express sample app using Eco templating engine.
This file contains hidden or 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
var express = require('express'); | |
var app = express.createServer(); | |
app.configure(function () { | |
app.use(app.router); | |
}); | |
app.set('views', __dirname + '/views'); | |
app.set('view engine', 'html'); | |
app.register('.html', require('eco')); | |
app.get('/', function (req, res) { | |
res.render('test', { foo: 'bar' }); | |
}); | |
app.listen(8080); | |
console.log('listening on port 8080...'); |
This file contains hidden or 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
<% layout('layout_site') %> | |
<h2>Main Layout</h2> | |
<p> | |
This is the main page layout. | |
It is wrapped by the <t>layout_site</t> layout. | |
</p> | |
<%- body %> |
This file contains hidden or 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
<!doctype html> | |
<head> | |
<meta charset=utf-8> | |
<title>Nested Layouts Demo</title> | |
</head> | |
<body> | |
<h1>Site Layout</h1> | |
<p> | |
This is the master site layout. | |
It is not wrapped by a layout. | |
</p> | |
<%- body %> | |
</body> | |
</html> |
This file contains hidden or 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
<% layout('layout_main') %> | |
<h3>Index Page</h3> | |
<p> | |
This is the main page content. | |
It is wrapped by the <t>layout_main</t> layout. | |
</p> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When I run this on Express 2.2.2, I get this error:
But if I tweak
require('eco')
torequire('ejs')
, it works as expected.