diff --git a/.gitignore b/.gitignore index 252c5ae..a7ed15c 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ runner.js jquery.mustache.js dojox yui3 +commonjs.mustache.js diff --git a/Rakefile b/Rakefile index 3298479..2946e97 100644 --- a/Rakefile +++ b/Rakefile @@ -14,8 +14,9 @@ task :spec desc "Package for CommonJS" task :commonjs do puts "Packaging for CommonJS" - `mkdir lib` - `cp mustache.js lib/mustache.js` + source = "mustache-commonjs" + target_jq = "commonjs.mustache.js" + `cat #{source}/#{target_jq}.tpl.pre mustache.js #{source}/#{target_jq}.tpl.post > #{target_jq}` puts "Done." end diff --git a/mustache-commonjs/commonjs.mustache.js.tpl.post b/mustache-commonjs/commonjs.mustache.js.tpl.post new file mode 100644 index 0000000..885803f --- /dev/null +++ b/mustache-commonjs/commonjs.mustache.js.tpl.post @@ -0,0 +1,7 @@ + +exports.name = Mustache.name; +exports.version = Mustache.version; + +exports.to_html = function() { + return Mustache.to_html.apply(this, arguments); +}; diff --git a/mustache-commonjs/commonjs.mustache.js.tpl.pre b/mustache-commonjs/commonjs.mustache.js.tpl.pre new file mode 100644 index 0000000..5e33b34 --- /dev/null +++ b/mustache-commonjs/commonjs.mustache.js.tpl.pre @@ -0,0 +1,6 @@ +/* + * CommonJS-compatible mustache.js module + * + * See http://github.com/janl/mustache.js for more info. + */ +