mozilla / connect-cachify

Express connect middleware to provide easy frontend caching for Node.js
Mozilla Public License 2.0
131 stars 21 forks source link

cachify injects stuff into the global namespace #16

Closed lloyd closed 12 years ago

lloyd commented 12 years ago
$ node
> require('connect-cachify');
{ setup: [Function],
  cachify_js: [Function],
  cachify_css: [Function],
  cachify: [Function] }
> cachify_js
[Function]

In BrowserID, we actually rely on this behavior (maybe accidentally?). In our templates we use cachify functions and we never actually pass them in.

I'd think it might be safer to not inject into the global namespace. I'd write a patch if you agreed, but what do you think?

seanmonstar commented 12 years ago

Keep the global clean! And, I imagine express lets us define default function helpers to templates.

lloyd commented 12 years ago

yes! @zcarter taught me this one:

res.local('cachify_js', cachify.cachify_js);

is all we would have to add to keep things going in browserid.

ozten commented 12 years ago

My bad. Please fix.