Permalink
Browse files

add lodash support

  • Loading branch information...
1 parent 9079894 commit 6253d1622cd59a89592d2cd9a22104c80dfafd90 @abalandin abalandin committed Nov 18, 2013
Showing with 23 additions and 0 deletions.
  1. +22 −0 lib/engines/lodash.js
  2. +1 −0 package.json
View
@@ -0,0 +1,22 @@
+var jst = require('../index.js')
+ , _ = require('lodash');
+
+// Returns a string of js with the compiled template
+module.exports = function( options, nm, file_contents ){
+
+ // override those settings
+ ['evaluate', 'interpolate', 'escape'].forEach(function(key){
+ if( !options[key] ) return;
+ if( !_.isRegExp(options[key]) ) options[key] = new RegExp(options[key]);
+ });
+
+ var func;
+ try {
+ func = options.namespace + '["'+ nm +'"] = '+ _.template(file_contents, null, options).source + ';\n'
+ } catch( e ){
+ console.error( 'Error processing '+ nm, e, e.stack);
+ return '/* Unable to compile ' + nm + ' */\n';
+ }
+
+ return func;
+};
View
@@ -20,6 +20,7 @@
"handlebars": "~1.0.2beta",
"jqtpl": "~1.0.9",
"underscore": "~1.3.3",
+ "lodash": "~2.3.0",
"async": "~0.1.18",
"coffee-script": "~1.2.0",
"watchr": "~1.0.0",

0 comments on commit 6253d16

Please sign in to comment.