Skip to content

Instantly share code, notes, and snippets.

@dawnerd
Created August 4, 2011 23:15
Show Gist options
  • Save dawnerd/1126548 to your computer and use it in GitHub Desktop.
Save dawnerd/1126548 to your computer and use it in GitHub Desktop.
node masher
module.exports = function(app) {
app.helpers({
getJS: function(key) {
var output = '';
app.configure('development', function(){
try {
var files = app.set('masher_config').JAVASCRIPT[key];
for(var i = 0, c = files.length; i < c; i++) {
var file = files[i].replace('./public', '');
output += '<script src="'+file+'"></script>';
}
} catch(err) {
throw new Error(err);
}
});
app.configure('production', function(){
try {
output = '<script src="/ui/compressed/js/'+key+'-'+app.set("mashed_version")+'.min.js"></script>';
} catch(err) {
throw new Error(err);
}
});
return output;
},
getCSS: function(key) {
var output = '';
app.configure('development', function(){
try {
var files = app.set('masher_config').CSS[key];
for(var i = 0, c = files.length; i < c; i++) {
var file = files[i].replace('./public', '');
output += '<link rel="stylesheet" href="'+file+'">';
}
} catch(err) {
throw new Error(err);
}
});
app.configure('production', function(){
try {
output = '<link rel="stylesheet" href="/ui/compressed/css/'+key+'-'+app.set("mashed_version")+'.min.css">';
} catch(err) {
throw new Error(err);
}
});
return output;
}
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment