Skip to content

Instantly share code, notes, and snippets.

@cfurrow
Created November 14, 2010 23:48
Show Gist options
  • Save cfurrow/676236 to your computer and use it in GitHub Desktop.
Save cfurrow/676236 to your computer and use it in GitHub Desktop.
// ...
var templates = require('./haml_loader');
// ...
// List all items, return html
app.get('/items/all',function(req,res){
Item.find().all(function(items){
var item_haml = templates['item'];
var output = "";
for(var i=0; i<items.length; i++){
var item = items[i];
// the 'item' template requires two locals, the item name, and the item description
output += item_haml({name:item.name,description:item.description});
}
res.send(output); // returns the html
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment