Skip to content

Commit

Permalink
Update examples
Browse files Browse the repository at this point in the history
Fix minir perf issues
  • Loading branch information
s3u committed Dec 13, 2010
1 parent 819c6d2 commit d08fb49
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion examples/express/ejs/app.js
Expand Up @@ -18,7 +18,7 @@ function main(app) {
}); });
} }


// Fire up // Fire up the resource server
var server = express.createServer(); var server = express.createServer();
server.use(resource(main)); server.use(resource(main));
server.listen(3000); server.listen(3000);
Expand Down
3 changes: 2 additions & 1 deletion examples/express/ejs/views/layout.ejs
@@ -1,6 +1,7 @@
<html> <html>
<body> <body>
<h1>Items</h1> <h1>Title here</h1>

<%- body %> <%- body %>
</body> </body>
</html> </html>
12 changes: 7 additions & 5 deletions examples/express/hbs/app.js
Expand Up @@ -12,11 +12,13 @@ function main(app) {
app.resource('/', { app.resource('/', {
'get' : function(req, res) { 'get' : function(req, res) {
res.render('items.hbs', { res.render('items.hbs', {
title: 'Hello World', locals: {
items: [ title: 'Hello World',
{ name: 'item1', description: 'This is item 1'}, items: [
{ name: 'item2', description: 'This is item 2' }, { name: 'item1', description: 'This is item 1'},
{ name: 'item3', email: 'This is item 3' }] { name: 'item2', description: 'This is item 2' },
{ name: 'item3', email: 'This is item 3' }]
}
}); });
} }
}); });
Expand Down
5 changes: 4 additions & 1 deletion examples/express/hbs/views/items.hbs
@@ -1,3 +1,6 @@
{{title}}
<ul id="items"> <ul id="items">
{{> item}} {{#items}}
<li> {{ name }} &lt; {{ description }} &gt;</li>
{{/items}
</ul> </ul>
14 changes: 9 additions & 5 deletions examples/express/hbs/views/layout.hbs
@@ -1,6 +1,10 @@
<html> <html>
<body> <head>
<h1>Items</h1> <title>{{title}}</title>
<%- body %> </head>
</body> <body>
</html> This is body

{{{body}}}
</body>
</html>
4 changes: 2 additions & 2 deletions lib/middleware/resource.js
Expand Up @@ -66,7 +66,7 @@ module.exports = function resource(fn) {
// Special handling for OPTIONS /* // Special handling for OPTIONS /*
if('options' == method && '/*' == req.url) { if('options' == method && '/*' == req.url) {
var supported = ['OPTIONS']; var supported = ['OPTIONS'];
for(i = 0; i < paths.length; i++) { for(i = 0, len = paths.length; i < len; i++) {
for (name in paths[i]) { for (name in paths[i]) {
// TODO: Hate using underscores. There should be a better way to hide these // TODO: Hate using underscores. There should be a better way to hide these
if (name.charAt(0) != '_' && paths[i].hasOwnProperty(name)) { if (name.charAt(0) != '_' && paths[i].hasOwnProperty(name)) {
Expand All @@ -88,7 +88,7 @@ module.exports = function resource(fn) {
return; return;
} }


for (i = 0; i < paths.length; i++) { for (i = 0, len = paths.length; i < len; i++) {
var path = paths[i]._path; var path = paths[i]._path;
var keys = paths[i]._keys; var keys = paths[i]._keys;
var matches = path.exec(pathname); var matches = path.exec(pathname);
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,7 +1,7 @@
{ {
"name": "resource-router", "name": "resource-router",
"description": "A connect-compatible resource-orinted router for building RESTful applications", "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)", "author": "Subbu Allamaraju <subbu@subbu.org> (http://www.subbu.org)",
"dependencies": { "connect": ">= 0.3.0" }, "dependencies": { "connect": ">= 0.3.0" },
"keywords": ["framework", "rest", "resource", "restful"], "keywords": ["framework", "rest", "resource", "restful"],
Expand Down

0 comments on commit d08fb49

Please sign in to comment.