6
ROOT = File.expand_path('..', __FILE__)
7
MUSTACHE_JS = File.read(File.join(ROOT, 'mustache.js'))
10
match = MUSTACHE_JS.match(/exports\.version = "([^"]+)";/)
15
ENV['FILE'] || 'mustache.min.js'
18
desc "Run all tests, requires vows (see http://vowsjs.org)"
23
desc "Minify to #{minified_file}, requires UglifyJS (see http://marijnhaverbeke.nl/uglifyjs)"
25
sh "uglifyjs mustache.js > #{minified_file}"
28
desc "Run JSHint, requires jshint (see http://www.jshint.com)"
30
sh "jshint mustache.js"
33
# Creates a task that uses the various template wrappers to make a wrapped
34
# output file. There is some extra complexity because Dojo and YUI use
35
# different final locations.
36
def templated_build(name, opts={})
38
source = File.join("wrappers", short)
39
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
40
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
42
CLEAN.include(opts[:location] ? opts[:location] : target_js)
44
desc "Package for #{name}"
45
task short.to_sym => dependencies do
46
puts "Packaging for #{name}"
48
mkdir_p opts[:location] if opts[:location]
51
"#{source}/mustache.js.pre",
53
"#{source}/mustache.js.post"
56
open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
57
files.each {|file| f << File.read(file) }
60
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
64
templated_build "jQuery"
65
templated_build "MooTools"
66
templated_build "Dojo", :location => "dojox/string"
67
templated_build "YUI3", :location => "yui3/mustache"
68
templated_build "qooxdoo"