Permalink
Browse files

changed handlers to export the registered instance

  • Loading branch information...
1 parent ce00431 commit 41f41b0ba70a4c96b479ad03c4176952caded467 @khrome khrome committed Jun 9, 2013
Showing with 33 additions and 14 deletions.
  1. +4 −1 handler-coffee.js
  2. +4 −1 handler-css.js
  3. +7 −2 handler-js.js
  4. +17 −9 handler-less.js
  5. +1 −1 package.json
View
@@ -22,6 +22,9 @@ var CoffeeScriptHandler = new Class({
};
}
});
-Resource.registerHandler('coffee', new CoffeeScriptHandler());
+
+var instance = new CoffeeScriptHandler();
+Resource.registerHandler('coffee', instance);
+CoffeeScriptHandler.instance = instance;
module.exports = CoffeeScriptHandler;
View
@@ -20,5 +20,8 @@ var CSSHandler = new Class({
};
}
});
-Resource.registerHandler('css', new CSSHandler());
+var instance = new CSSHandler();
+Resource.registerHandler('css', instance);
+CSSHandler.instance = instance;
+
module.exports = CSSHandler;
View
@@ -41,8 +41,13 @@ var JavascriptMainHandler = new Class({
};
}
});
-Resource.registerHandler('js', new JavascriptHandler());
-Resource.registerHandler('main', new JavascriptMainHandler());
+var instance = new JavascriptHandler();
+Resource.registerHandler('js', instance);
+JavascriptHandler.instance = instance;
+
+var instance = new JavascriptMainHandler();
+Resource.registerHandler('main', instance);
+JavascriptMainHandler.instance = instance;
module.exports = JavascriptHandler;
module.exports.Main = JavascriptMainHandler;
View
@@ -12,15 +12,21 @@ var LessHandler = new Class({
parts.pop();
var dir = parts.join('/');
try{
- var parser = new(less.Parser)({
- paths: [dir], // Specify search paths for @import directives
- filename: path // Specify a filename, for better error messages
- });
+ var parser = new(less.Parser)({
+ paths: [dir], // Specify search paths for @import directives
+ filename: path // Specify a filename, for better error messages
+ });
parser.parse(options.body, function (e, tree) {
- if(e) callback('/* ERROR : '+e+'*'+'/');
- else{
- var css = tree.toCSS({ compress: options.compact || false });
- callback(css);
+ if(e){
+ console.log('LESS ERROR', e);
+ callback('/* ERROR : '+e.message+'*'+'/');
+ }else{
+ try{
+ var css = tree.toCSS({ compress: options.compact || false });
+ callback(css);
+ }catch(ex){
+ console.log('LESS ERROR', ex);
+ }
}
});
}catch(ex){
@@ -38,5 +44,7 @@ var LessHandler = new Class({
};
}
});
-Resource.registerHandler('less', new LessHandler());
+var instance = new LessHandler();
+Resource.registerHandler('less', instance);
+LessHandler.instance = instance;
module.exports = LessHandler;
View
@@ -1,7 +1,7 @@
{
"name": "protolus-resource",
"homepage": "https://github.com/Protolus/protolus-resource",
- "version": "0.0.8-alpha",
+ "version": "0.0.9-alpha",
"main": "protolus-resource.js",
"description": "a CommonJS based server-side resource delivery mechanism with client side shim",
"keywords": [

0 comments on commit 41f41b0

Please sign in to comment.