Просмотр исходного кода

Merge remote branch 'jhs/master'

* jhs/master:
  Output the "Done" message as before
  Actually ignore comment tags; and correct the expected output in the test case
  Refactor template-style builds into a common function
  Execute commands properly. You can see what's happening, and errors halt the build
  Build CommonJS just like any other target, using "pre" and "post" wrappers
tags/0.3.0
Jan Lehnardt 16 лет назад
Родитель
Сommit
f226c0b437
4 измененных файлов: 35 добавлений и 35 удалений
  1. +1
    -0
      .gitignore
  2. +21
    -35
      Rakefile
  3. +7
    -0
      mustache-commonjs/commonjs.mustache.js.tpl.post
  4. +6
    -0
      mustache-commonjs/commonjs.mustache.js.tpl.pre

+ 1
- 0
.gitignore Просмотреть файл

@@ -2,3 +2,4 @@ runner.js
jquery.mustache.js
dojox
yui3
commonjs.mustache.js

+ 21
- 35
Rakefile Просмотреть файл

@@ -11,44 +11,30 @@ end
desc "Run all specs"
task :spec

desc "Package for CommonJS"
task :commonjs do
puts "Packaging for CommonJS"
`mkdir lib`
`cp mustache.js lib/mustache.js`
puts "Done."
def templated_build(name, opts={})
# Create a rule that uses the .tmpl.{pre,post} stuff to make a final, wrapped, output file.
# There is some extra complexity because Dojo and YUI3 use different template files and final locations.
short = name.downcase
source = "mustache-#{short}"
dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")

desc "Package for #{name}"
task short.to_sym => dependencies do
target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"

puts "Packaging for #{name}"
sh "mkdir -p #{opts[:location]}" if opts[:location]
sh "cat #{source}/#{target_js}.tpl.pre mustache.js #{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}"
puts "Done, see #{opts[:location] || '.'}/#{target_js}"
end
end

desc "Package for jQuery"
task :jquery do
puts "Packaging for jQuery"
source = "mustache-jquery"
target_jq = "jquery.mustache.js"
`cat #{source}/#{target_jq}.tpl.pre mustache.js #{source}/#{target_jq}.tpl.post > #{target_jq}`
puts "Done, see ./#{target_jq}"
end

desc "Package for dojo"
task :dojo do
puts "Packaging for dojo"
source = "mustache-dojo"
target_js = "mustache.js"
`mkdir -p dojox; mkdir -p dojox/string`
`cat #{source}/#{target_js}.tpl.pre mustache.js #{source}/#{target_js}.tpl.post > dojox/string/#{target_js}`
puts "Done, see ./dojox/string/#{target_js} Include using dojo.require('dojox.string.mustache.'); "
end

desc "Package for YUI3"
task :yui3 do
puts "Packaging for YUI3"
source = "mustache-yui3"
target_js = "mustache.js"
`mkdir -p yui3; mkdir -p yui3/mustache`
`cat #{source}/#{target_js}.tpl.pre mustache.js #{source}/#{target_js}.tpl.post > yui3/mustache/#{target_js}`
puts "Done, see ./yui3/mustache/#{target_js}"
end
templated_build "CommonJS"
templated_build "jQuery"
templated_build "Dojo", :location => "dojox/string"
templated_build "YUI3", :location => "yui3/mustache"

desc "Remove temporary files."
task :clean do
`git clean -fdx`
sh "git clean -fdx"
end

+ 7
- 0
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);
};

+ 6
- 0
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.
*/


Загрузка…
Отмена
Сохранить