Permalink
Browse files

Update examples

Fix minir perf issues
  • Loading branch information...
1 parent 819c6d2 commit d08fb49e84cc93e304457dc76448861d7b4b1d73 @s3u committed Dec 13, 2010
@@ -18,7 +18,7 @@ function main(app) {
});
}
-// Fire up
+// Fire up the resource server
var server = express.createServer();
server.use(resource(main));
server.listen(3000);
@@ -1,6 +1,7 @@
<html>
<body>
- <h1>Items</h1>
+ <h1>Title here</h1>
+
<%- body %>
</body>
</html>
@@ -12,11 +12,13 @@ function main(app) {
app.resource('/', {
'get' : function(req, res) {
res.render('items.hbs', {
- title: 'Hello World',
- items: [
- { name: 'item1', description: 'This is item 1'},
- { name: 'item2', description: 'This is item 2' },
- { name: 'item3', email: 'This is item 3' }]
+ locals: {
+ title: 'Hello World',
+ items: [
+ { name: 'item1', description: 'This is item 1'},
+ { name: 'item2', description: 'This is item 2' },
+ { name: 'item3', email: 'This is item 3' }]
+ }
});
}
});
@@ -1,3 +1,6 @@
+{{title}}
<ul id="items">
- {{> item}}
+ {{#items}}
+ <li> {{ name }} &lt; {{ description }} &gt;</li>
+ {{/items}
</ul>
@@ -1,6 +1,10 @@
<html>
- <body>
- <h1>Items</h1>
- <%- body %>
- </body>
-</html>
+ <head>
+ <title>{{title}}</title>
+ </head>
+ <body>
+ This is body
+
+ {{{body}}}
+ </body>
+</html>
@@ -66,7 +66,7 @@ module.exports = function resource(fn) {
// Special handling for OPTIONS /*
if('options' == method && '/*' == req.url) {
var supported = ['OPTIONS'];
- for(i = 0; i < paths.length; i++) {
+ for(i = 0, len = paths.length; i < len; i++) {
for (name in paths[i]) {
// TODO: Hate using underscores. There should be a better way to hide these
if (name.charAt(0) != '_' && paths[i].hasOwnProperty(name)) {
@@ -88,7 +88,7 @@ module.exports = function resource(fn) {
return;
}
- for (i = 0; i < paths.length; i++) {
+ for (i = 0, len = paths.length; i < len; i++) {
var path = paths[i]._path;
var keys = paths[i]._keys;
var matches = path.exec(pathname);
View
@@ -1,7 +1,7 @@
{
"name": "resource-router",
"description": "A connect-compatible resource-orinted router for building RESTful applications",
- "version": "0.3.0",
+ "version": "0.3.1",
"author": "Subbu Allamaraju <subbu@subbu.org> (http://www.subbu.org)",
"dependencies": { "connect": ">= 0.3.0" },
"keywords": ["framework", "rest", "resource", "restful"],

0 comments on commit d08fb49

Please sign in to comment.