選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

Rakefile 1.5KB

16年前
Parser rewrite This commit is a complete rewrite of the core mustache.js file with two main goals: 1) a major performance boost and 2) better compliance with the mustache spec. In order to improve performance templates are pre-compiled to JavaScript functions. These compiled functions take a view, a partials object, and an optional callback as arguments. They are cached to prevent unnecessary re-compilation of an already compiled template. Both of these enhancements facilitate a generous boost in performance. A few other notes: - The mustache.js file is now both browser and CommonJS ready without any modification. - The API exposes two main methods: Mustache.compile and Mustache.render. The former is used to generate a function for a given template, while the latter is a higher-level function that is used to compile and render a template in one shot. Mustache.to_html is still available for backwards compatibility. - The concept of pragmas is removed to conform more closely to the original mustache spec. The dot symbol still works to reference the current item in an array. - The parser is much more strict about whitespace than it was before. The rule is simple: if a line contains only a non-variable tag (i.e. not {{tag}} or {{{tag}}}) and whitespace, that line is ignored in the output. Users may use the "space" option when compiling templates to preserve every whitespace character in the original template. - The parser is able to provide detailed information about where errors occur when parsing and rendering templates, including the line number and surrounding code context.
14年前
16年前
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. require 'rake'
  2. require 'rake/clean'
  3. task :default => :spec
  4. desc "Run all specs"
  5. task :spec do
  6. require 'rspec/core/rake_task'
  7. RSpec::Core::RakeTask.new(:spec) do |t|
  8. #t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
  9. t.pattern = 'spec/*_spec.rb'
  10. end
  11. end
  12. def version
  13. File.read("mustache.js").match('version = "([^\"]+)";$')[1]
  14. end
  15. # Creates a rule that uses the .tmpl.{pre,post} stuff to make a final,
  16. # wrapped, output file. There is some extra complexity because Dojo and YUI3
  17. # use different template files and final locations.
  18. def templated_build(name, opts={})
  19. short = name.downcase
  20. source = File.join("wrappers", short)
  21. dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
  22. target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
  23. CLEAN.include(opts[:location] ? opts[:location] : target_js)
  24. desc "Package for #{name}"
  25. task short.to_sym => dependencies do
  26. puts "Packaging for #{name}"
  27. mkdir_p opts[:location] if opts[:location]
  28. files = [
  29. "#{source}/mustache.js.pre",
  30. 'mustache.js',
  31. "#{source}/mustache.js.post"
  32. ]
  33. open("#{opts[:location] || '.'}/#{target_js}", 'w') do |f|
  34. files.each {|file| f << File.read(file) }
  35. end
  36. puts "Done, see #{opts[:location] || '.'}/#{target_js}"
  37. end
  38. end
  39. templated_build "jQuery"
  40. templated_build "MooTools"
  41. templated_build "Dojo", :location => "dojox/string"
  42. templated_build "YUI3", :location => "yui3/mustache"
  43. templated_build "RequireJS"
  44. templated_build "qooxdoo"