Created
August 4, 2011 23:15
-
-
Save dawnerd/1126548 to your computer and use it in GitHub Desktop.
node masher
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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