Skip to content

Instantly share code, notes, and snippets.

@polotek
Forked from creationix/route.js
Created December 5, 2011 19:19
Show Gist options
  • Save polotek/1434862 to your computer and use it in GitHub Desktop.
Save polotek/1434862 to your computer and use it in GitHub Desktop.
Sanity check for async template idea
Creationix.route("GET", "/", function (req, res, params, next) {
loadIndex(function (err, home) {
home.render("frontindex",
links: query("index", "links"),
articles: loadArticles()
}, function (err, html) {
if (err) return next(err);
res.writeHead(200, {
"Content-Length": Buffer.byteLength(html),
"Content-Type": "text/html; charset=utf-8"
});
res.end(html);
});
});
}),
<!doctype html>
<html>
<head>
<title>{this.title}</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
{this.topbar(data.links)}
<div class="container_16">
<div class="grid_11">
<div class="section">
{this.summary(data.articles)}</div>
</div>
<div class="grid_5">
<div class="section">Sidebar</div>
</div>
</div>
{this.footer()}
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment