You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TESTING.md 1.9KB

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 anni fa
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 anni fa
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. ## Running the mustache.js test suite
  2. The mustache.js test suite uses the [RSpec](http://rspec.info/) testing
  3. framework. In order to run the tests you'll need to install [Ruby](http://ruby-lang.org/)
  4. as well as the `rake`, `rspec` (>=2), and `json` [RubyGems](http://rubygems.org/).
  5. ### How to install Ruby and the required gems from source
  6. Make sure you have the required tools to compile it:
  7. $ apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev
  8. Download and extract the Ruby source, and install it:
  9. $ wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
  10. $ tar xvzf stable-snapshot.tar.gz
  11. $ cd ruby
  12. $ ./configure && make && make install
  13. Download and extract RubyGems, and install it:
  14. $ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.12.tgz
  15. $ tar xzvf rubygems-1.8.12.tgz
  16. $ cd rubygems-1.8.12
  17. $ ruby setup.rb
  18. If you want to update RubyGems:
  19. $ gem update --system
  20. Install the required gems:
  21. $ gem install rake rspec json
  22. That's it!
  23. ### How to run the tests
  24. The mustache.js test suite currently uses 4 different JavaScript runtime engines
  25. to maximize portability across platforms and browsers. They are:
  26. * node
  27. * SpiderMonkey (Mozilla, Firefox)
  28. * JavaScriptCore (WebKit, Safari)
  29. * Rhino (Mozilla, Java)
  30. When the test suite runs it will automatically determine which platforms are
  31. available on your machine and run on all of them. The suite must run on at least
  32. one platform in order to succeed.
  33. Once you have at least one JavaScript platform installed, you can run the test
  34. suite with the following command:
  35. $ rake
  36. ### How to create a test
  37. All test files live in the spec/_files directory. To create a new test:
  38. * Create a template file called `somename.mustache`
  39. * Create a JavaScript file containing the view called `somename.js`
  40. * Create a text file with the expected result called `somename.txt`