mozilla / connect-cachify

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

Create cachify helper as well as optional config for cachify_js and cachify_css #4

Closed ozten closed 12 years ago

ozten commented 12 years ago

A new function cachify would output an array of strings with no HTML tag. This way user's could iterate the output and write their own HTML script or link tags.

cachify('/js/main.min.js');

We should add an optional argument to cachify_js and cahify_css to control the formatting of tags.

cachify_js('/js/main.min.js', {format: '<script src="%s" defer></script>'});
lloyd commented 12 years ago

+1.

var html = "";
cachify('/js/main.min.js').forEach(function(file) {
  html += util.format('<script src="%s" defer></script>\n', file);
});
return html;
ozten commented 12 years ago

Fixed in https://github.com/mozilla/connect-cachify/commit/fe8df0c486071d304def714bf61a3a79f3ed0dc3

Made a slight tweak to syntax, example at the bottom of https://github.com/mozilla/connect-cachify/blob/master/docs/API.md