From dadf072d405fb44782afd016488e0d9db04c6e66 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sun, 18 Oct 2009 19:04:24 +0200 Subject: [PATCH] add jquery package generation, run `rake jquery`, somebody please port this to ruby :) --- .gitignore | 5 +++++ Rakefile | 18 ++++++++++++++++-- mustache-jquery/jquery.mustache.js.tpl.post | 6 ++++++ mustache-jquery/jquery.mustache.js.tpl.pre | 9 +++++++++ 4 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 mustache-jquery/jquery.mustache.js.tpl.post create mode 100644 mustache-jquery/jquery.mustache.js.tpl.pre diff --git a/.gitignore b/.gitignore index 1886df5..34478aa 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,8 @@ mustache-commonjs/examples/view_partial.txt mustache-commonjs/lib/mustache.js mustache-commonjs/test/mustache_test.js mustache-commonjs/test/mustache_test.rb +mustache-jquery/jquery.mustache.js +mustache-jquery/LICENSE +mustache-jquery/README.md +mustache-jquery/examples/ +mustache-jquery/test/ diff --git a/Rakefile b/Rakefile index ab2bab9..24bd6c1 100644 --- a/Rakefile +++ b/Rakefile @@ -16,9 +16,23 @@ end task :commonjs do print "Packaging for CommonJS\n" target = "mustache-commonjs" - files = "LICENSE README.md test examples" - `cp -r #{files} #{target}` + copy_distfiles(target); `mkdir #{target}/lib` `cp mustache.js #{target}/lib` print "Done, see ./#{target}\n" end + +task :jquery do + print "Packaging for jQuery\n" + target = "mustache-jquery/" + target_jq = "#{target}/jquery.mustache.js" + `cat #{target_jq}.tpl.pre mustache.js #{target_jq}.tpl.post > #{target_jq}` + copy_distfiles(target); + print "Done, see ./#{target}\n" +end + +private +def copy_distfiles(target) + files = "LICENSE README.md test examples" + `cp -r #{files} #{target}` +end diff --git a/mustache-jquery/jquery.mustache.js.tpl.post b/mustache-jquery/jquery.mustache.js.tpl.post new file mode 100644 index 0000000..bcc9907 --- /dev/null +++ b/mustache-jquery/jquery.mustache.js.tpl.post @@ -0,0 +1,6 @@ + + $.mustache = function(template, view) { + return Mustache.to_html(template, view); + }; + +})(jQuery); diff --git a/mustache-jquery/jquery.mustache.js.tpl.pre b/mustache-jquery/jquery.mustache.js.tpl.pre new file mode 100644 index 0000000..b4d8af5 --- /dev/null +++ b/mustache-jquery/jquery.mustache.js.tpl.pre @@ -0,0 +1,9 @@ +/* +Shameless port of a shameless port +@defunkt => @janl => @aq + +See http://github.com/defunkt/mustache for more info. +*/ + +;(function($) { +