Skip to content

Instantly share code, notes, and snippets.

@polotek
Forked from creationix/route.js
Created December 6, 2011 18:50
Show Gist options
  • Save polotek/1439395 to your computer and use it in GitHub Desktop.
Save polotek/1439395 to your computer and use it in GitHub Desktop.
Sanity check for async template idea
Creationix.route("GET", "/", function (req, res, params, next) {
render("frontindex", {
title: query("index", "title"),
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>@title()</title>
<link rel="stylesheet" href="style.css"/>
</head>
<body>
@render("topbar", this)
<div class="container_16">
<div class="grid_11">
<div class="section">@render("summary", articles)</div>
</div>
<div class="grid_5">
<div class="section">Sidebar</div>
</div>
</div>
@render("footer", this)
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment