Created
November 14, 2010 23:48
-
-
Save cfurrow/676236 to your computer and use it in GitHub Desktop.
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 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