[Pkg-javascript-commits] [mustache.js] 02/08: New upstream version 2.3.0

Martín Ferrari tincho at debian.org
Sun Nov 13 19:43:51 UTC 2016


This is an automated email from the git hooks/post-receive script.

tincho pushed a commit to branch tincho
in repository mustache.js.

commit 4c9be15d47ad4e3fef959fd5fe96a080645c7d7a
Author: Martín Ferrari <tincho at debian.org>
Date:   Sun Nov 13 19:03:03 2016 +0100

    New upstream version 2.3.0
---
 .eslintrc                                          |  20 +
 .gitignore                                         |  14 +-
 .gitmodules                                        |   3 +
 .travis.yml                                        |  20 +-
 .zuul.yml                                          |   8 +
 CHANGELOG.md                                       | 284 +++++++
 LICENSE                                            |  26 +-
 MIGRATING.md                                       |  50 ++
 README.md                                          | 698 ++++++++++-----
 Rakefile                                           |  83 +-
 TESTING.md                                         |  75 --
 bin/mustache                                       | 136 +++
 bower.json                                         |  20 +
 hooks/install-hooks.sh                             |  22 +
 hooks/pre-commit                                   |  89 ++
 mustache.js                                        | 934 +++++++++++++--------
 mustache.js.nuspec                                 |   2 +-
 mustache.min.js                                    |   7 +-
 package.json                                       |  61 ++
 spec/_files/ampersand_escape.js                    |   3 -
 spec/_files/apostrophe.js                          |   1 -
 spec/_files/array_of_partials_partial.js           |   3 -
 spec/_files/array_of_strings.js                    |   1 -
 spec/_files/array_of_strings.mustache              |   1 -
 spec/_files/array_of_strings_options.js            |   1 -
 spec/_files/array_of_strings_options.mustache      |   2 -
 spec/_files/array_of_strings_options.txt           |   1 -
 spec/_files/array_partial.js                       |   5 -
 spec/_files/bom_as_whitespace.js                   |   1 +
 spec/_files/bom_as_whitespace.mustache             |   1 +
 spec/_files/bom_as_whitespace.txt                  |   1 +
 spec/_files/bug_11_eating_whitespace.js            |   3 -
 spec/_files/comments.js                            |   5 -
 spec/_files/complex.txt                            |   6 -
 spec/_files/empty_partial.2.mustache               |   1 -
 spec/_files/empty_partial.js                       |   3 -
 spec/_files/empty_sections.js                      |   1 -
 spec/_files/empty_template.js                      |   1 -
 spec/_files/empty_template.txt                     |   1 -
 spec/_files/error_not_found.js                     |   1 -
 spec/_files/escaped.js                             |   7 -
 spec/_files/escaped.mustache                       |   3 -
 spec/_files/escaped.txt                            |   3 -
 spec/_files/higher_order_sections.js               |   9 -
 spec/_files/higher_order_sections.txt              |   1 -
 spec/_files/inverted_section.js                    |   3 -
 spec/_files/inverted_section.mustache              |   2 -
 spec/_files/nesting.txt                            |   4 -
 spec/_files/partial_recursion.2.mustache           |   4 -
 spec/_files/partial_recursion.js                   |  11 -
 spec/_files/partial_recursion.mustache             |   4 -
 spec/_files/partial_recursion.txt                  |   3 -
 spec/_files/reuse_of_enumerables.js                |   6 -
 spec/_files/template_partial.2.mustache            |   1 -
 spec/_files/template_partial.js                    |   8 -
 spec/_files/two_in_a_row.mustache                  |   1 -
 spec/_files/two_sections.js                        |   1 -
 spec/_files/two_sections.txt                       |   1 -
 spec/_files/unescaped.js                           |   5 -
 spec/_files/unescaped.mustache                     |   1 -
 spec/_files/unknown_pragma.js                      |   1 -
 spec/_files/unknown_pragma.mustache                |   1 -
 spec/_files/unknown_pragma.txt                     |   1 -
 spec/_files/view_partial.js                        |  19 -
 spec/_files/whitespace_partial.js                  |  19 -
 spec/mustache_spec.rb                              | 276 ------
 test/_files/ampersand_escape.js                    |   3 +
 {spec => test}/_files/ampersand_escape.mustache    |   0
 {spec => test}/_files/ampersand_escape.txt         |   0
 test/_files/apostrophe.js                          |   4 +
 {spec => test}/_files/apostrophe.mustache          |   0
 {spec => test}/_files/apostrophe.txt               |   0
 test/_files/array_of_strings.js                    |   3 +
 test/_files/array_of_strings.mustache              |   1 +
 {spec => test}/_files/array_of_strings.txt         |   0
 test/_files/avoids_obj_prototype_in_view_cache.js  |   4 +
 .../avoids_obj_prototype_in_view_cache.mustache    |   1 +
 test/_files/avoids_obj_prototype_in_view_cache.txt |   1 +
 test/_files/backslashes.js                         |   3 +
 test/_files/backslashes.mustache                   |   7 +
 test/_files/backslashes.txt                        |   7 +
 test/_files/bug_11_eating_whitespace.js            |   3 +
 .../_files/bug_11_eating_whitespace.mustache       |   0
 {spec => test}/_files/bug_11_eating_whitespace.txt |   0
 test/_files/bug_length_property.js                 |   3 +
 test/_files/bug_length_property.mustache           |   1 +
 test/_files/bug_length_property.txt                |   1 +
 test/_files/changing_delimiters.js                 |   4 +
 test/_files/changing_delimiters.mustache           |   1 +
 test/_files/changing_delimiters.txt                |   1 +
 test/_files/check_falsy.js                         |   7 +
 test/_files/check_falsy.mustache                   |   1 +
 test/_files/check_falsy.txt                        |   1 +
 test/_files/cli.json                               |   3 +
 test/_files/cli.mustache                           |   1 +
 test/_files/cli.txt                                |   1 +
 test/_files/cli_with_partials.json                 |  14 +
 test/_files/cli_with_partials.mustache             |   7 +
 test/_files/cli_with_partials.txt                  |   2 +
 test/_files/comments.js                            |   5 +
 {spec => test}/_files/comments.mustache            |   0
 {spec => test}/_files/comments.txt                 |   0
 {spec => test}/_files/complex.js                   |  12 +-
 {spec => test}/_files/complex.mustache             |   2 +-
 test/_files/complex.txt                            |   6 +
 test/_files/context_lookup.js                      |   8 +
 test/_files/context_lookup.mustache                |   1 +
 test/_files/context_lookup.txt                     |   1 +
 {spec => test}/_files/delimiters.js                |   4 +-
 {spec => test}/_files/delimiters.mustache          |   2 +-
 {spec => test}/_files/delimiters.txt               |   0
 test/_files/disappearing_whitespace.js             |   4 +
 test/_files/disappearing_whitespace.mustache       |   1 +
 test/_files/disappearing_whitespace.txt            |   1 +
 {spec => test}/_files/dot_notation.js              |  14 +-
 {spec => test}/_files/dot_notation.mustache        |   4 +-
 {spec => test}/_files/dot_notation.txt             |   4 +-
 {spec => test}/_files/double_render.js             |   4 +-
 {spec => test}/_files/double_render.mustache       |   0
 {spec => test}/_files/double_render.txt            |   0
 test/_files/empty_list.js                          |   3 +
 test/_files/empty_list.mustache                    |   4 +
 test/_files/empty_list.txt                         |   1 +
 test/_files/empty_sections.js                      |   1 +
 {spec => test}/_files/empty_sections.mustache      |   0
 {spec => test}/_files/empty_sections.txt           |   0
 test/_files/empty_string.js                        |   6 +
 test/_files/empty_string.mustache                  |   1 +
 test/_files/empty_string.txt                       |   1 +
 test/_files/empty_template.js                      |   1 +
 {spec => test}/_files/empty_template.mustache      |   0
 .../_files/empty_template.txt                      |   0
 test/_files/error_not_found.js                     |   3 +
 {spec => test}/_files/error_not_found.mustache     |   0
 test/_files/error_not_found.txt                    |   0
 test/_files/escaped.js                             |   7 +
 test/_files/escaped.mustache                       |   2 +
 test/_files/escaped.txt                            |   2 +
 test/_files/falsy.js                               |   8 +
 test/_files/falsy.mustache                         |  12 +
 test/_files/falsy.txt                              |  12 +
 test/_files/falsy_array.js                         |  10 +
 test/_files/falsy_array.mustache                   |   3 +
 test/_files/falsy_array.txt                        |   6 +
 test/_files/grandparent_context.js                 |  19 +
 test/_files/grandparent_context.mustache           |  10 +
 test/_files/grandparent_context.txt                |  17 +
 test/_files/higher_order_sections.js               |   9 +
 .../_files/higher_order_sections.mustache          |   0
 test/_files/higher_order_sections.txt              |   1 +
 test/_files/implicit_iterator.js                   |   8 +
 test/_files/implicit_iterator.mustache             |   7 +
 test/_files/implicit_iterator.txt                  |   3 +
 test/_files/included_tag.js                        |   3 +
 test/_files/included_tag.mustache                  |   1 +
 test/_files/included_tag.txt                       |   1 +
 test/_files/inverted_section.js                    |   3 +
 test/_files/inverted_section.mustache              |   3 +
 {spec => test}/_files/inverted_section.txt         |   2 +
 {spec => test}/_files/keys_with_questionmarks.js   |   4 +-
 .../_files/keys_with_questionmarks.mustache        |   0
 {spec => test}/_files/keys_with_questionmarks.txt  |   0
 test/_files/malicious_template.js                  |   1 +
 test/_files/malicious_template.mustache            |   5 +
 .../_files/malicious_template.txt                  |   1 +
 test/_files/multiline_comment.js                   |   1 +
 test/_files/multiline_comment.mustache             |   6 +
 test/_files/multiline_comment.txt                  |   1 +
 test/_files/nested_dot.js                          |   1 +
 test/_files/nested_dot.mustache                    |   1 +
 test/_files/nested_dot.txt                         |   1 +
 test/_files/nested_higher_order_sections.js        |   8 +
 test/_files/nested_higher_order_sections.mustache  |   1 +
 test/_files/nested_higher_order_sections.txt       |   1 +
 test/_files/nested_iterating.js                    |   8 +
 test/_files/nested_iterating.mustache              |   1 +
 test/_files/nested_iterating.txt                   |   1 +
 {spec => test}/_files/nesting.js                   |   4 +-
 {spec => test}/_files/nesting.mustache             |   0
 test/_files/nesting.txt                            |   3 +
 test/_files/nesting_same_name.js                   |   8 +
 test/_files/nesting_same_name.mustache             |   1 +
 test/_files/nesting_same_name.txt                  |   1 +
 test/_files/null_lookup_array.js                   |   9 +
 test/_files/null_lookup_array.mustache             |   3 +
 test/_files/null_lookup_array.txt                  |   3 +
 test/_files/null_lookup_object.js                  |  31 +
 test/_files/null_lookup_object.mustache            |   9 +
 test/_files/null_lookup_object.txt                 |   7 +
 {spec => test}/_files/null_string.js               |   5 +-
 {spec => test}/_files/null_string.mustache         |   3 +-
 {spec => test}/_files/null_string.txt              |   1 +
 test/_files/null_view.js                           |   4 +
 test/_files/null_view.mustache                     |   1 +
 test/_files/null_view.txt                          |   1 +
 test/_files/partial_array.js                       |   3 +
 .../_files/partial_array.mustache                  |   0
 .../_files/partial_array.partial                   |   2 +-
 .../_files/partial_array.txt                       |   1 -
 test/_files/partial_array_of_partials.js           |   8 +
 .../_files/partial_array_of_partials.mustache      |   0
 .../_files/partial_array_of_partials.partial       |   0
 .../_files/partial_array_of_partials.txt           |   0
 .../_files/partial_array_of_partials_implicit.js   |   4 +-
 .../partial_array_of_partials_implicit.mustache    |   0
 .../partial_array_of_partials_implicit.partial     |   0
 .../_files/partial_array_of_partials_implicit.txt  |   0
 test/_files/partial_empty.js                       |   3 +
 .../_files/partial_empty.mustache                  |   0
 test/_files/partial_empty.partial                  |   0
 .../_files/partial_empty.txt                       |   1 -
 test/_files/partial_template.js                    |   6 +
 .../_files/partial_template.mustache               |   2 +-
 test/_files/partial_template.partial               |   1 +
 .../_files/partial_template.txt                    |   0
 test/_files/partial_view.js                        |  14 +
 .../_files/partial_view.mustache                   |   2 +-
 .../_files/partial_view.partial                    |   0
 .../_files/partial_view.txt                        |   1 -
 test/_files/partial_whitespace.js                  |  14 +
 .../_files/partial_whitespace.mustache             |   2 +-
 .../_files/partial_whitespace.partial              |   2 +-
 .../_files/partial_whitespace.txt                  |   1 -
 {spec => test}/_files/recursion_with_same_names.js |   6 +-
 .../_files/recursion_with_same_names.mustache      |   0
 .../_files/recursion_with_same_names.txt           |   1 +
 test/_files/reuse_of_enumerables.js                |   6 +
 .../_files/reuse_of_enumerables.mustache           |   0
 {spec => test}/_files/reuse_of_enumerables.txt     |   0
 {spec => test}/_files/section_as_context.js        |   9 +-
 {spec => test}/_files/section_as_context.mustache  |   0
 {spec => test}/_files/section_as_context.txt       |   6 +-
 test/_files/section_functions_in_partials.js       |   7 +
 test/_files/section_functions_in_partials.mustache |   3 +
 test/_files/section_functions_in_partials.partial  |   1 +
 test/_files/section_functions_in_partials.txt      |   3 +
 {spec => test}/_files/simple.js                    |   6 +-
 .../_files/simple.mustache                         |   0
 {spec => test}/_files/simple.txt                   |   0
 test/_files/string_as_context.js                   |   4 +
 test/_files/string_as_context.mustache             |   5 +
 test/_files/string_as_context.txt                  |   5 +
 {spec => test}/_files/two_in_a_row.js              |   4 +-
 test/_files/two_in_a_row.mustache                  |   1 +
 {spec => test}/_files/two_in_a_row.txt             |   0
 test/_files/two_sections.js                        |   1 +
 {spec => test}/_files/two_sections.mustache        |   0
 test/_files/two_sections.txt                       |   0
 test/_files/unescaped.js                           |   6 +
 test/_files/unescaped.mustache                     |   1 +
 {spec => test}/_files/unescaped.txt                |   0
 test/_files/uses_props_from_view_prototype.js      |  30 +
 .../_files/uses_props_from_view_prototype.mustache |   1 +
 test/_files/uses_props_from_view_prototype.txt     |   1 +
 test/_files/whitespace.js                          |   4 +
 test/_files/whitespace.mustache                    |   4 +
 test/_files/whitespace.txt                         |   4 +
 test/_files/zero_view.js                           |   1 +
 test/_files/zero_view.mustache                     |   1 +
 test/_files/zero_view.txt                          |   1 +
 test/cli-test.js                                   | 144 ++++
 test/context-test.js                               |  61 ++
 test/create-browser-suite.js                       |  14 +
 test/helper.js                                     |   4 +
 test/mustache-spec-test.js                         |  89 ++
 test/parse-test.js                                 | 106 +++
 test/render-helper.js                              |  55 ++
 test/render-test-browser-tmpl.mustache             |  38 +
 test/render-test.js                                |  35 +
 test/scanner-test.js                               |  78 ++
 wrappers/commonjs/mustache.js.tpl.post             |   8 -
 wrappers/commonjs/mustache.js.tpl.pre              |   6 -
 wrappers/commonjs/package.json                     |   8 -
 wrappers/dojo/mustache.js.post                     |   4 +
 .../dojo/{mustache.js.tpl.pre => mustache.js.pre}  |   0
 wrappers/dojo/mustache.js.tpl.post                 |   4 -
 wrappers/jquery/jquery.mustache.js.tpl.post        |   6 -
 wrappers/jquery/mustache.js.post                   |  13 +
 ...{jquery.mustache.js.tpl.pre => mustache.js.pre} |   0
 wrappers/mootools/mustache.js.post                 |   5 +
 wrappers/mootools/mustache.js.pre                  |   2 +
 wrappers/qooxdoo/mustache.js.post                  |   9 +
 ...qooxdoo.mustache.js.tpl.pre => mustache.js.pre} |  93 +-
 wrappers/qooxdoo/qooxdoo.mustache.js.tpl.post      |   9 -
 wrappers/requirejs/requirejs.mustache.js.tpl.post  |   3 -
 wrappers/requirejs/requirejs.mustache.js.tpl.pre   |   6 -
 wrappers/yui3/mustache.js.post                     |   4 +
 .../yui3/{mustache.js.tpl.pre => mustache.js.pre}  |   0
 wrappers/yui3/mustache.js.tpl.post                 |   4 -
 289 files changed, 3172 insertions(+), 1279 deletions(-)

diff --git a/.eslintrc b/.eslintrc
new file mode 100644
index 0000000..0e2d7ce
--- /dev/null
+++ b/.eslintrc
@@ -0,0 +1,20 @@
+{
+  "env": {
+    "browser": true,
+    "node": true
+  },
+  "rules": {
+    "func-names": 2,
+    "no-mixed-spaces-and-tabs": 2,
+    "quotes": [2, "single", "avoid-escape"],
+    "semi": 2,
+    "keyword-spacing": 2,
+    "space-before-function-paren": 2,
+
+    "curly": 0,
+    "consistent-return": 0,
+    "no-use-before-define": 0,
+    "no-process-exit": 0,
+    "strict": 0
+  }
+}
\ No newline at end of file
diff --git a/.gitignore b/.gitignore
index 65128cd..6ad717e 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,12 +1,10 @@
-# ignore temp vim files
-*.swp
-.DS_Store
-.rvmrc
-runner.js
-lib
+node_modules
 jquery.mustache.js
-qooxdoo.mustache.js
+mootools.mustache.js
 dojox
 yui3
-requirejs.mustache.js
+qooxdoo.mustache.js
+test/render-test-browser.js
+npm-debug.log
 
+test/render-test-browser.js
\ No newline at end of file
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 0000000..9e2fdf8
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,3 @@
+[submodule "test/spec"]
+	path = test/spec
+	url = https://github.com/mustache/spec
diff --git a/.travis.yml b/.travis.yml
index b52599e..2a12320 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -1,5 +1,15 @@
-rvm:
-  - 1.9.2
-before_script:
-  - sudo apt-get -y install xulrunner-2.0
-  - gem install rspec
+language: node_js
+node_js:
+  - 0.8
+  - '0.10'
+  - 0.12
+  - 4
+before_install:
+  - npm install -g npm at 2.x
+script:
+  - npm test
+  - "test $TRAVIS_PULL_REQUEST != 'false' || test $TRAVIS_NODE_VERSION != '4' || npm run test-browser"
+env:
+  global:
+  - secure: L0dg0jr2fwkc2tPwP5svybILPBn2qdLzMrWc5tEXg3MPcy8D59Gvf+ri7INqo+ETPM20o5CsaDCH+LHUNS/V0G4VG1ajvsy7d8uh3hnb/K6VfVui/CjsHIqOcOZrbxVxgyX+iMXEXAj0+Syow9uDQHVhrz1qqad1n79likNCXa4=
+  - secure: J4vbGKivULEHWRWExAWDLkFk9EDU7E6Ny+iRc/oKxXHnBYn9oL2Hfc1J92fOttaFtUzpz7r5FaNa3DGlyAI0wimq5GY8KJQGcquoskerXucd8iJbLCs3nxDeShl4UwHpDIXF8xbH/rUIkrGSKnktf0McMRIyeN95hzug0nxOwAw=
diff --git a/.zuul.yml b/.zuul.yml
new file mode 100644
index 0000000..b2efeea
--- /dev/null
+++ b/.zuul.yml
@@ -0,0 +1,8 @@
+ui: mocha-bdd
+browsers:
+  - name: chrome
+    version: latest
+  - name: firefox
+    version: latest
+  - name: ie
+    version: 9..latest
\ No newline at end of file
diff --git a/CHANGELOG.md b/CHANGELOG.md
new file mode 100644
index 0000000..0c499eb
--- /dev/null
+++ b/CHANGELOG.md
@@ -0,0 +1,284 @@
+# Change Log
+
+All notable changes to this project will be documented in this file.
+This project adheres to [Semantic Versioning](http://semver.org/).
+
+## [2.3.0] / 8 November 2016
+
+### Minor
+
+ * [#540]: Add optional `output` argument to mustache CLI, by [@wizawu].
+ * [#597]: Add compatibility with amdclean, by [@mightyplow].
+
+### Dev
+
+ * [#553]: Assert `null` lookup when rendering an unescaped value, by [@dasilvacontin].
+ * [#580], [#610]: Ignore eslint for greenkeeper updates, by [@phillipj].
+ * [#560]: Fix CLI tests for Windows, by [@kookookchoozeus].
+ * Run browser tests w/node v4, by [@phillipj].
+
+### Docs
+
+ * [#542]: Add API documentation to README, by [@tomekwi].
+ * [#546]: Add missing syntax highlighting to README code blocks, by [@pra85].
+ * [#569]: Update Ctemplate links in README, by [@mortonfox].
+ * [#592]: Change "loadUser" to "loadUser()" in README, by [@Flaque].
+ * [#593]: Adding doctype to HTML code example in README, by [@calvinf].
+
+### Dependencies
+
+ * eslint -> 2.2.0. Breaking changes fix by [@phillipj]. [#548]
+ * eslint -> 2.5.1.
+ * mocha -> 3.0.2.
+ * zuul -> 3.11.0.
+
+## [2.2.1] / 13 December 2015
+
+### Fixes
+
+ * Improve HTML escaping, by [@phillipj].
+ * Fix inconsistency in defining global mustache object, by [@simast].
+ * Fix switch-case indent error, by [@norfish].
+ * Unpin chai and eslint versions, by [@dasilvacontin].
+ * Update README.md with proper grammar, by [@EvanLovely].
+ * Update mjackson username in README, by [@mjackson].
+ * Remove syntax highlighting in README code sample, by [@imagentleman].
+ * Fix typo in README, by [@Xcrucifier].
+ * Fix link typo in README, by [@keirog].
+
+## [2.2.0] / 15 October 2015
+
+### Added
+
+ * Add Partials support to CLI, by [@palkan].
+
+### Changed
+
+ * Move install instructions to README's top, by [@mateusortiz]
+ * Improved devhook install output, by [@ShashankaNataraj].
+ * Clarifies and improves language in documentation, by [@jfmercer].
+ * Linting CLI tool, by [@phillipj].
+ * npm 2.x and node v4 on Travis, by [@phillipj].
+
+### Fixes
+
+ * Fix README spelling error to "aforementioned", by [@djchie].
+ * Equal error message test in .render() for server and browser, by [@phillipj].
+
+### Dependencies
+
+ * chai -> 3.3.0
+ * eslint -> 1.6.0
+
+## [2.1.3] / 23 July 2015
+
+### Added
+
+ * Throw error when providing .render() with invalid template type, by [@phillipj].
+ * Documents use of string literals containing double quotes, by [@jfmercer].
+
+### Changed
+
+ * Move mustache gif to githubusercontent, by [@Andersos].
+
+### Fixed
+
+ * Update UMD Shim to be resilient to HTMLElement global pollution, by [@mikesherov].
+
+## [2.1.2] / 17 June 2015
+
+### Added
+
+ * Mustache global definition ([#466]) by [@yousefcisco].
+
+## [2.1.1] / 11 June 2015
+
+### Added
+
+ * State that we use semver on the change log, by [@dasilvacontin].
+ * Added version links to change log, by [@dasilvacontin].
+
+### Fixed
+
+ * Bugfix for using values from view's context prototype, by [@phillipj].
+ * Improve test with undefined/null lookup hit using dot notation, by [@dasilvacontin].
+ * Bugfix for null/undefined lookup hit when using dot notation, by [@phillipj].
+ * Remove moot `version` property from bower.json, by [@kkirsche].
+ * bower.json doesn't require a version bump via hook, by [@dasilvacontin].
+
+
+## [2.1.0] / 5 June 2015
+
+ * Added license attribute to package.json, by [@pgilad].
+ * Minor changes to make mustache.js compatible with both WSH and ASP, by [@nagaozen].
+ * Improve CLI view parsing error, by [@phillipj].
+ * Bugfix for view context cache, by [@phillipj].
+
+## [2.0.0] / 27 Mar 2015
+
+ * Fixed lookup not stopping upon finding `undefined` or `null` values, by [@dasilvacontin].
+ * Refactored pre-commit hook, by [@dasilvacontin].
+
+## [1.2.0] / 24 Mar 2015
+
+ * Added -v option to CLI, by [@phillipj].
+ * Bugfix for rendering Number when it serves as the Context, by [@phillipj].
+ * Specified files in package.json for a cleaner install, by [@phillipj].
+
+## [1.1.0] / 18 Feb 2015
+
+ * Refactor Writer.renderTokens() for better readability, by [@phillipj].
+ * Cleanup tests section in readme, by [@phillipj].
+ * Added JSHint to tests/CI, by [@phillipj].
+ * Added node v0.12 on travis, by [@phillipj].
+ * Created command line tool, by [@phillipj].
+ * Added *falsy* to Inverted Sections description in README, by [@kristijanmatic].
+
+## [1.0.0] / 20 Dec 2014
+
+  * Inline tag compilation, by [@mjackson].
+  * Fixed AMD registration, volo package.json entry, by [@jrburke].
+  * Added spm support, by [@afc163].
+  * Only access properties of objects on Context.lookup, by [@cmbuckley].
+
+## [0.8.2] / 17 Mar 2014
+
+  * Supporting Bower through a bower.json file.
+
+## [0.8.1] / 3 Jan 2014
+
+  * Fix usage of partial templates.
+
+## [0.8.0] / 2 Dec 2013
+
+  * Remove compile* writer functions, use mustache.parse instead. Smaller API.
+  * Throw an error when rendering a template that contains higher-order sections and
+    the original template is not provided.
+  * Remove low-level Context.make function.
+  * Better code readability and inline documentation.
+  * Stop caching templates by name.
+
+## [0.7.3] / 5 Nov 2013
+
+  * Don't require the original template to be passed to the rendering function
+    when using compiled templates. This is still required when using higher-order
+    functions in order to be able to extract the portion of the template
+    that was contained by that section. Fixes [#262].
+  * Performance improvements.
+
+## [0.7.2] / 27 Dec 2012
+
+  * Fixed a rendering bug ([#274]) when using nested higher-order sections.
+  * Better error reporting on failed parse.
+  * Converted tests to use mocha instead of vows.
+
+## [0.7.1] / 6 Dec 2012
+
+  * Handle empty templates gracefully. Fixes [#265], [#267], and [#270].
+  * Cache partials by template, not by name. Fixes [#257].
+  * Added Mustache.compileTokens to compile the output of Mustache.parse. Fixes
+    [#258].
+
+## [0.7.0] / 10 Sep 2012
+
+  * Rename Renderer => Writer.
+  * Allow partials to be loaded dynamically using a callback (thanks
+    [@TiddoLangerak] for the suggestion).
+  * Fixed a bug with higher-order sections that prevented them from being
+    passed the raw text of the section from the original template.
+  * More concise token format. Tokens also include start/end indices in the
+    original template.
+  * High-level API is consistent with the Writer API.
+  * Allow partials to be passed to the pre-compiled function (thanks
+    [@fallenice]).
+  * Don't use eval (thanks [@cweider]).
+
+## [0.6.0] / 31 Aug 2012
+
+  * Use JavaScript's definition of falsy when determining whether to render an
+    inverted section or not. Issue [#186].
+  * Use Mustache.escape to escape values inside {{}}. This function may be
+    reassigned to alter the default escaping behavior. Issue [#244].
+  * Fixed a bug that clashed with QUnit (thanks [@kannix]).
+  * Added volo support (thanks [@guybedford]).
+
+[2.3.0]: https://github.com/janl/mustache.js/compare/v2.2.1...v2.3.0
+[2.2.1]: https://github.com/janl/mustache.js/compare/v2.2.0...v2.2.1
+[2.2.0]: https://github.com/janl/mustache.js/compare/v2.1.3...v2.2.0
+[2.1.3]: https://github.com/janl/mustache.js/compare/v2.1.2...v2.1.3
+[2.1.2]: https://github.com/janl/mustache.js/compare/v2.1.1...v2.1.2
+[2.1.1]: https://github.com/janl/mustache.js/compare/v2.1.0...v2.1.1
+[2.1.0]: https://github.com/janl/mustache.js/compare/v2.0.0...v2.1.0
+[2.0.0]: https://github.com/janl/mustache.js/compare/v1.2.0...v2.0.0
+[1.2.0]: https://github.com/janl/mustache.js/compare/v1.1.0...v1.2.0
+[1.1.0]: https://github.com/janl/mustache.js/compare/v1.0.0...v1.1.0
+[1.0.0]: https://github.com/janl/mustache.js/compare/0.8.2...v1.0.0
+[0.8.2]: https://github.com/janl/mustache.js/compare/0.8.1...0.8.2
+[0.8.1]: https://github.com/janl/mustache.js/compare/0.8.0...0.8.1
+[0.8.0]: https://github.com/janl/mustache.js/compare/0.7.3...0.8.0
+[0.7.3]: https://github.com/janl/mustache.js/compare/0.7.2...0.7.3
+[0.7.2]: https://github.com/janl/mustache.js/compare/0.7.1...0.7.2
+[0.7.1]: https://github.com/janl/mustache.js/compare/0.7.0...0.7.1
+[0.7.0]: https://github.com/janl/mustache.js/compare/0.6.0...0.7.0
+[0.6.0]: https://github.com/janl/mustache.js/compare/0.5.2...0.6.0
+
+[#186]: https://github.com/janl/mustache.js/issues/186
+[#244]: https://github.com/janl/mustache.js/issues/244
+[#257]: https://github.com/janl/mustache.js/issues/257
+[#258]: https://github.com/janl/mustache.js/issues/258
+[#262]: https://github.com/janl/mustache.js/issues/262
+[#265]: https://github.com/janl/mustache.js/issues/265
+[#267]: https://github.com/janl/mustache.js/issues/267
+[#270]: https://github.com/janl/mustache.js/issues/270
+[#274]: https://github.com/janl/mustache.js/issues/274
+[#466]: https://github.com/janl/mustache.js/issues/466
+[#540]: https://github.com/janl/mustache.js/issues/540
+[#542]: https://github.com/janl/mustache.js/issues/542
+[#546]: https://github.com/janl/mustache.js/issues/546
+[#548]: https://github.com/janl/mustache.js/issues/548
+[#553]: https://github.com/janl/mustache.js/issues/553
+[#560]: https://github.com/janl/mustache.js/issues/560
+[#569]: https://github.com/janl/mustache.js/issues/569
+[#580]: https://github.com/janl/mustache.js/issues/580
+[#592]: https://github.com/janl/mustache.js/issues/592
+[#593]: https://github.com/janl/mustache.js/issues/593
+[#597]: https://github.com/janl/mustache.js/issues/597
+[#610]: https://github.com/janl/mustache.js/issues/610
+
+[@afc163]: https://github.com/afc163
+[@Andersos]: https://github.com/Andersos
+[@calvinf]: https://github.com/calvinf
+[@cmbuckley]: https://github.com/cmbuckley
+[@cweider]: https://github.com/cweider
+[@dasilvacontin]: https://github.com/dasilvacontin
+[@djchie]: https://github.com/djchie
+[@EvanLovely]: https://github.com/EvanLovely
+[@fallenice]: https://github.com/fallenice
+[@Flaque]: https://github.com/Flaque
+[@guybedford]: https://github.com/guybedford
+[@imagentleman]: https://github.com/imagentleman
+[@jfmercer]: https://github.com/jfmercer
+[@jrburke]: https://github.com/jrburke
+[@kannix]: https://github.com/kannix
+[@keirog]: https://github.com/keirog
+[@kkirsche]: https://github.com/kkirsche
+[@kookookchoozeus]: https://github.com/kookookchoozeus
+[@kristijanmatic]: https://github.com/kristijanmatic
+[@mateusortiz]: https://github.com/mateusortiz
+[@mightyplow]: https://github.com/mightyplow
+[@mikesherov]: https://github.com/mikesherov
+[@mjackson]: https://github.com/mjackson
+[@mortonfox]: https://github.com/mortonfox
+[@nagaozen]: https://github.com/nagaozen
+[@norfish]: https://github.com/norfish
+[@palkan]: https://github.com/palkan
+[@pgilad]: https://github.com/pgilad
+[@phillipj]: https://github.com/phillipj
+[@pra85]: https://github.com/pra85
+[@ShashankaNataraj]: https://github.com/ShashankaNataraj
+[@simast]: https://github.com/simast
+[@TiddoLangerak]: https://github.com/TiddoLangerak
+[@tomekwi]: https://github.com/tomekwi
+[@wizawu]: https://github.com/wizawu
+[@Xcrucifier]: https://github.com/Xcrucifier
+[@yousefcisco]: https://github.com/yousefcisco
diff --git a/LICENSE b/LICENSE
index 395e263..4df7d1a 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,23 +1,11 @@
 The MIT License
 
 Copyright (c) 2009 Chris Wanstrath (Ruby)
-Copyright (c) 2010 Jan Lehnardt (JavaScript)
+Copyright (c) 2010-2014 Jan Lehnardt (JavaScript)
+Copyright (c) 2010-2015 The mustache.js community
 
-Permission is hereby granted, free of charge, to any person obtaining
-a copy of this software and associated documentation files (the
-"Software"), to deal in the Software without restriction, including
-without limitation the rights to use, copy, modify, merge, publish,
-distribute, sublicense, and/or sell copies of the Software, and to
-permit persons to whom the Software is furnished to do so, subject to
-the following conditions:
- 
-The above copyright notice and this permission notice shall be
-included in all copies or substantial portions of the Software.
- 
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
-NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
-LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
-OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
-WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\ No newline at end of file
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/MIGRATING.md b/MIGRATING.md
new file mode 100644
index 0000000..28d5156
--- /dev/null
+++ b/MIGRATING.md
@@ -0,0 +1,50 @@
+# Migrating Guide
+
+## Moving to mustache.js v2
+
+### Overview
+
+mustache.js v2 introduces a bug fix that breaks compatibility with older versions: fixing null and undefined lookup.
+
+When mustache.js tries to render a variable `{{name}}`, it executes a `lookup` function to figure out which value it should render. This function looks up the value for the key `name` in the current context, and if there is no such key in the current context it looks up the parent contexts recursively.
+
+Value lookup should stop whenever the key exists in the context. However, due to a bug, this was not happening when the value was `null` or `undefined` even though the key existed in the context.
+
+Here's a simple example of the same template rendered with both mustache.js v1 and v2:
+
+Template:
+```mustache
+{{#friends}}
+{{name}}'s twitter is: {{twitter}}
+{{/friends}}
+```
+
+View:
+```json
+{
+    "name": "David",
+    "twitter": "@dasilvacontin",
+    "friends": [
+        {
+            "name": "Phillip",
+            "twitter": "@phillipjohnsen"
+        },
+        {
+            "name": "Jan",
+            "twitter": null
+        }
+    ]
+}
+```
+
+Rendered using mustache.js v1:
+```text
+Phillip's twitter is: @phillipjohnsen
+Jan's twitter is: @dasilvacontin
+```
+
+Rendered using mustache.js v2:
+```text
+Phillip's twitter is: @phillipjohnsen
+Jan's twitter is:
+```
\ No newline at end of file
diff --git a/README.md b/README.md
index 578df7c..9b6ffb7 100644
--- a/README.md
+++ b/README.md
@@ -1,302 +1,620 @@
-# mustache.js — Logic-less {{mustache}} templates with JavaScript
+# mustache.js - Logic-less {{mustache}} templates with JavaScript
 
 > What could be more logical awesome than no logic at all?
 
-[mustache.js](http://github.com/janl/mustache.js) is an implementation of the
-[Mustache](http://mustache.github.com/) templating system in JavaScript.
+[![Build Status](https://travis-ci.org/janl/mustache.js.svg?branch=master)](https://travis-ci.org/janl/mustache.js) [![Gitter chat](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/janl/mustache.js)
 
-[Mustache](http://mustache.github.com/) is a logic-less template syntax. It can
-be used for HTML, config files, source code - anything. It works by expanding
-tags in a template using values provided in a hash or object.
+[mustache.js](http://github.com/janl/mustache.js) is an implementation of the [mustache](http://mustache.github.com/) template system in JavaScript.
 
-We call it "logic-less" because there are no if statements, else clauses, or for
-loops. Instead there are only tags. Some tags are replaced with a value, some
-nothing, and others a series of values.
+[Mustache](http://mustache.github.com/) is a logic-less template syntax. It can be used for HTML, config files, source code - anything. It works by expanding tags in a template using values provided in a hash or object.
 
-For a language-agnostic overview of Mustache's template syntax, see the
-`mustache(5)` [manpage](http://mustache.github.com/mustache.5.html).
+We call it "logic-less" because there are no if statements, else clauses, or for loops. Instead there are only tags. Some tags are replaced with a value, some nothing, and others a series of values.
+
+For a language-agnostic overview of mustache's template syntax, see the `mustache(5)` [manpage](http://mustache.github.com/mustache.5.html).
 
 ## Where to use mustache.js?
 
-You can use mustache.js to render templates in many various scenarios where you
-can use JavaScript. For example, you can render templates in a browser,
-server-side using [node](http://nodejs.org/), in [CouchDB](http://couchdb.apache.org/)
-views, or in almost any other environment where you can use JavaScript.
+You can use mustache.js to render mustache templates anywhere you can use JavaScript. This includes web browsers, server-side environments such as [node](http://nodejs.org/), and [CouchDB](http://couchdb.apache.org/) views.
+
+mustache.js ships with support for both the [CommonJS](http://www.commonjs.org/) module API and the [Asynchronous Module Definition](https://github.com/amdjs/amdjs-api/wiki/AMD) API, or AMD.
+
+And this will be your templates after you use Mustache:
+
+!['stache](https://cloud.githubusercontent.com/assets/288977/8779228/a3cf700e-2f02-11e5-869a-300312fb7a00.gif)
+
+## Install
+
+You can get Mustache via npm.
+
+```bash
+$ npm install mustache --save
+```
+or install with bower:
+
+```bash
+$ bower install --save mustache
+```
+
+## Command line tool
+
+mustache.js is shipped with a node based command line tool. It might be installed as a global tool on your computer to render a mustache template of some kind
+
+```bash
+$ npm install -g mustache
+
+$ mustache dataView.json myTemplate.mustache > output.html
+```
+
+also supports stdin.
+
+```bash
+$ cat dataView.json | mustache - myTemplate.mustache > output.html
+```
+
+or as a package.json `devDependency` in a build process maybe?
+
+```bash
+$ npm install mustache --save-dev
+```
+
+```json
+{
+  "scripts": {
+    "build": "mustache dataView.json myTemplate.mustache > public/output.html"
+  }
+}
+```
+```bash
+$ npm run build
+```
+
+The command line tool is basically a wrapper around `Mustache.render` so you get all the features.
+
+If your templates use partials you should pass paths to partials using `-p` flag:
+
+```bash
+$ mustache -p path/to/partial1.mustache -p path/to/partial2.mustache dataView.json myTemplate.mustache
+```
 
 ## Who uses mustache.js?
 
-An updated list of mustache.js users is kept [on the Github wiki](http://wiki.github.com/janl/mustache.js/beard-competition).
-Add yourself or your company if you use mustache.js!
+An updated list of mustache.js users is kept [on the Github wiki](http://wiki.github.com/janl/mustache.js/beard-competition). Add yourself or your company if you use mustache.js!
+
+## Contributing
+
+mustache.js is a mature project, but it continues to actively invite maintainers. You can help out a high-profile project that is used in a lot of places on the web. There is [plenty](https://github.com/janl/mustache.js/issues) of [work](https://github.com/janl/mustache.js/pulls) to do. No big commitment required, if all you do is review a single [Pull Request](https://github.com/janl/mustache.js/pulls), you are a maintainer. And a hero.
+
+### Your First Contribution
+
+- review a [Pull Request](https://github.com/janl/mustache.js/pulls)
+- fix an [Issue](https://github.com/janl/mustache.js/issues)
+- update the [documentation](https://github.com/janl/mustache.js#usage)
+- make a website
+- write a tutorial
+
+* * *
 
 ## Usage
 
-Below is quick example how to use mustache.js:
+Below is a quick example how to use mustache.js:
 
-    var view = {
-      title: "Joe",
-      calc: function() {
-        return 2 + 4;
-      }
-    };
+```js
+var view = {
+  title: "Joe",
+  calc: function () {
+    return 2 + 4;
+  }
+};
 
-    var html = Mustache.to_html("{{title}} spends {{calc}}", view);
+var output = Mustache.render("{{title}} spends {{calc}}", view);
+```
 
-In this example, the `Mustache.to_html` function takes two parameters: 1) the
-[mustache](http://mustache.github.com/) template and 2) a `view` object that
-contains the data and code needed to render the template.
+In this example, the `Mustache.render` function takes two parameters: 1) the [mustache](http://mustache.github.com/) template and 2) a `view` object that contains the data and code needed to render the template.
 
+## API
 
-## Template Tag Types
+Following is an [rtype](https://git.io/rtype) signature of the most commonly used functions.
 
-There are several types of tags currently implemented in mustache.js.
+```js
+Mustache.render(
+  template  : String,
+  view      : Object,
+  partials? : Object,
+) => String
 
-### Simple Tags
+Mustache.parse(
+  template              : String,
+  tags = ['{{', '}}']   : Tags,
+) => String
 
-Tags are always surrounded by mustaches like this `{{foobar}}`.
+interface Tags [String, String]
+```
 
-    var view = {name: "Joe", say_hello: function(){ return "hello" }}
+## Templates
 
-    template = "{{say_hello}}, {{name}}"
+A [mustache](http://mustache.github.com/) template is a string that contains any number of mustache tags. Tags are indicated by the double mustaches that surround them. `{{person}}` is a tag, as is `{{#person}}`. In both examples we refer to `person` as the tag's key. There are several types of tags available in mustache.js, described below.
 
-#### Accessing values in nested objects (Dot Notation)
+There are several techniques that can be used to load templates and hand them to mustache.js, here are two of them:
 
-To access data logically grouped into nested objects, specify a '.' delimited
-path to the value.
+#### Include Templates
 
-    var contact = {
-      name: {first: "Bill", last: "Bobitybob" },
-      age: 37
-    }
+If you need a template for a dynamic part in a static website, you can consider including the template in the static HTML file to avoid loading templates separately. Here's a small example using `jQuery`:
 
-    template = "Hello, {{name.first}} {{name.last}}. You are {{age}} years old."
+```html
+<!DOCTYPE HTML>
+<html>
+<body onload="loadUser()">
+<div id="target">Loading...</div>
+<script id="template" type="x-tmpl-mustache">
+Hello {{ name }}!
+</script>
+</body>
+</html>
+```
 
-*NOTICE*: The dot notation feature was recently implemented for the 0.4
-  release, which is not out as of Nov 9 2011. You can find the feature in the
-  current master branch of mustachejs.
+```js
+function loadUser() {
+  var template = $('#template').html();
+  Mustache.parse(template);   // optional, speeds up future uses
+  var rendered = Mustache.render(template, {name: "Luke"});
+  $('#target').html(rendered);
+}
+```
 
-### Conditional Sections
+#### Load External Templates
 
-Conditional sections begin with `{{#condition}}` and end with
-`{{/condition}}`. When `condition` evaluates to true, the section is rendered,
-otherwise the whole block will output nothing at all. `condition` may be a
-function returning true/false or a simple boolean.
+If your templates reside in individual files, you can load them asynchronously and render them when they arrive. Another example using `jQuery`:
 
-    var view = {condition: function() {
-      // [...your code goes here...]
-      return true;
-    }}
+```js
+function loadUser() {
+  $.get('template.mst', function(template) {
+    var rendered = Mustache.render(template, {name: "Luke"});
+    $('#target').html(rendered);
+  });
+}
+```
 
-    {{#condition}}
-      I will be visible if condition is true
-    {{/condition}}
+### Variables
 
+The most basic tag type is a simple variable. A `{{name}}` tag renders the value of the `name` key in the current context. If there is no such key, nothing is rendered.
 
-### Enumerable Sections
+All variables are HTML-escaped by default. If you want to render unescaped HTML, use the triple mustache: `{{{name}}}`. You can also use `&` to unescape a variable.
 
-Enumerable Sections use the same syntax as condition sections do.
-`{{#shopping_items}}` and `{{/shopping_items}}`. Actually the view decides how
-mustache.js renders the section. If the view returns an array, it will
-iterator over the items. Use `{{.}}` to access the current item inside the
-enumeration section.
+If you want `{{name}}` _not_ to be interpreted as a mustache tag, but rather to appear exactly as `{{name}}` in the output, you must change and then restore the default delimiter. See the [Custom Delimiters](#custom-delimiters) section for more information.
 
-    var view = {name: "Joe's shopping card",
-                items: ["bananas", "apples"]}
+View:
 
-    var template = "{{name}}: <ul> {{#items}}<li>{{.}}</li>{{/items}} </ul>"
+```json
+{
+  "name": "Chris",
+  "company": "<b>GitHub</b>"
+}
+```
 
-    Outputs:
-    Joe's shopping card: <ul><li>bananas</li><li>apples</li></ul>
+Template:
 
+```
+* {{name}}
+* {{age}}
+* {{company}}
+* {{{company}}}
+* {{&company}}
+{{=<% %>=}}
+* {{company}}
+<%={{ }}=%>
+```
+
+Output:
+
+```html
+* Chris
+*
+* <b>GitHub</b>
+* <b>GitHub</b>
+* <b>GitHub</b>
+* {{company}}
+```
+
+JavaScript's dot notation may be used to access keys that are properties of objects in a view.
 
-### Higher Order Sections
+View:
 
-If a section key returns a function, it will be called and passed both the
-unrendered block of text and a renderer convenience function.
+```json
+{
+  "name": {
+    "first": "Michael",
+    "last": "Jackson"
+  },
+  "age": "RIP"
+}
+```
 
-Given this object:
+Template:
 
-    "name": "Tater",
-    "bolder": function() {
-      return function(text, render) {
-        return "<b>" + render(text) + '</b>'
-      }
-    }
+```html
+* {{name.first}} {{name.last}}
+* {{age}}
+```
+
+Output:
+
+```html
+* Michael Jackson
+* RIP
+```
+
+### Sections
+
+Sections render blocks of text one or more times, depending on the value of the key in the current context.
+
+A section begins with a pound and ends with a slash. That is, `{{#person}}` begins a `person` section, while `{{/person}}` ends it. The text between the two tags is referred to as that section's "block".
+
+The behavior of the section is determined by the value of the key.
+
+#### False Values or Empty Lists
+
+If the `person` key does not exist, or exists and has a value of `null`, `undefined`, `false`, `0`, or `NaN`, or is an empty string or an empty list, the block will not be rendered.
+
+View:
+
+```json
+{
+  "person": false
+}
+```
+
+Template:
+
+```html
+Shown.
+{{#person}}
+Never shown!
+{{/person}}
+```
+
+Output:
+
+```html
+Shown.
+```
+
+#### Non-Empty Lists
+
+If the `person` key exists and is not `null`, `undefined`, or `false`, and is not an empty list the block will be rendered one or more times.
+
+When the value is a list, the block is rendered once for each item in the list. The context of the block is set to the current item in the list for each iteration. In this way we can loop over collections.
+
+View:
+
+```json
+{
+  "stooges": [
+    { "name": "Moe" },
+    { "name": "Larry" },
+    { "name": "Curly" }
+  ]
+}
+```
+
+Template:
+
+```html
+{{#stooges}}
+<b>{{name}}</b>
+{{/stooges}}
+```
+
+Output:
 
-And this template:
+```html
+<b>Moe</b>
+<b>Larry</b>
+<b>Curly</b>
+```
 
-    {{#bolder}}Hi {{name}}.{{/bolder}}
+When looping over an array of strings, a `.` can be used to refer to the current item in the list.
 
-We'll get this output:
+View:
+
+```json
+{
+  "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"]
+}
+```
 
-    <b>Hi Tater.</b>
+Template:
 
-As you can see, we’re pre-processing the text in the block. This can be used
-to implement caching, filters (like syntax highlighting), etc.
+```html
+{{#musketeers}}
+* {{.}}
+{{/musketeers}}
+```
 
-You can use `this.name` to access the attribute `name` from your view.
+Output:
 
-### Dereferencing Sections
+```html
+* Athos
+* Aramis
+* Porthos
+* D'Artagnan
+```
 
-If your data has components that are logically grouped into nested objects,
-you may wish to dereference an object to access its values.
+If the value of a section variable is a function, it will be called in the context of the current item in the list on each iteration.
+
+View:
+
+```js
+{
+  "beatles": [
+    { "firstName": "John", "lastName": "Lennon" },
+    { "firstName": "Paul", "lastName": "McCartney" },
+    { "firstName": "George", "lastName": "Harrison" },
+    { "firstName": "Ringo", "lastName": "Starr" }
+  ],
+  "name": function () {
+    return this.firstName + " " + this.lastName;
+  }
+}
+```
+
+Template:
 
-Given this object:
+```html
+{{#beatles}}
+* {{name}}
+{{/beatles}}
+```
 
-    {
-      "name": "Bill",
-      "address": {
-        "street": "801 Streetly street",
-        "city": "Boston",
-        "state": "MA",
-        "zip" "02101"
-      }
+Output:
+
+```html
+* John Lennon
+* Paul McCartney
+* George Harrison
+* Ringo Starr
+```
+
+#### Functions
+
+If the value of a section key is a function, it is called with the section's literal block of text, un-rendered, as its first argument. The second argument is a special rendering function that uses the current view as its view argument. It is called in the context of the current view object.
+
+View:
+
+```js
+{
+  "name": "Tater",
+  "bold": function () {
+    return function (text, render) {
+      return "<b>" + render(text) + "</b>";
     }
+  }
+}
+```
 
-And this template:
+Template:
 
-    <h1>Contact: {{name}}</h1>
-    {{#address}}
-      <p>{{street}}</p>
-      <p>{{city}}, {{state}} {{zip}}</p>
-    {{/address}}
+```html
+{{#bold}}Hi {{name}}.{{/bold}}
+```
 
-We'll get this output:
+Output:
 
-    <h1>Contact: Bill</h1>
-      <p>801 Streetly street</p>
-      <p>Boston, MA 02101</p>
+```html
+<b>Hi Tater.</b>
+```
 
 ### Inverted Sections
 
-An inverted section opens with `{{^section}}` instead of `{{#section}}` and
-uses a boolean negative to evaluate. Empty arrays are considered falsy.
+An inverted section opens with `{{^section}}` instead of `{{#section}}`. The block of an inverted section is rendered only if the value of that section's tag is `null`, `undefined`, `false`, *falsy* or an empty list.
 
 View:
 
-    var inverted_section =  {
-      "repo": []
-    }
+```json
+{
+  "repos": []
+}
+```
 
 Template:
 
-    {{#repo}}<b>{{name}}</b>{{/repo}}
-    {{^repo}}No repos :({{/repo}}
+```html
+{{#repos}}<b>{{name}}</b>{{/repos}}
+{{^repos}}No repos :({{/repos}}
+```
+
+Output:
+
+```html
+No repos :(
+```
+
+### Comments
 
-Result:
+Comments begin with a bang and are ignored. The following template:
 
-    No repos :(
+```html
+<h1>Today{{! ignore me }}.</h1>
+```
 
+Will render as follows:
 
-### View Partials
+```html
+<h1>Today.</h1>
+```
 
-mustache.js supports a quite powerful but yet simple view partial mechanism.
-Use the following syntax for partials: `{{>partial_name}}`
+Comments may contain newlines.
 
-    var view = {
-      name: "Joe",
-      winnings: {
-        value: 1000,
-        taxed_value: function() {
-            return this.value - (this.value * 0.4);
-        }
-      }
-    };
+### Partials
 
-    var template = "Welcome, {{name}}! {{>winnings}}"
-    var partials = {
-      winnings: "You just won ${{value}} (which is ${{taxed_value}} after tax)"};
+Partials begin with a greater than sign, like {{> box}}.
 
-    var output = Mustache.to_html(template, view, partials)
+Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops.
 
-    output will be:
-    Welcome, Joe! You just won $1000 (which is $600 after tax)
+They also inherit the calling context. Whereas in ERB you may have this:
 
-You invoke a partial with `{{>winnings}}`. Invoking the partial `winnings`
-will tell mustache.js to look for a object in the context's property
-`winnings`. It will then use that object as the context for the template found
-in `partials` for `winnings`.
+```html+erb
+<%= partial :next_more, :start => start, :size => size %>
+```
 
-## Escaping
+Mustache requires only this:
 
-mustache.js does escape all values when using the standard double mustache
-syntax. Characters which will be escaped: `& \ " ' < >`. To disable escaping,
-simply use triple mustaches like `{{{unescaped_variable}}}`.
+```html
+{{> next_more}}
+```
 
-Example: Using `{{variable}}` inside a template for `5 > 2` will result in `5 > 2`, where as the usage of `{{{variable}}}` will result in `5 > 2`.
+Why? Because the `next_more.mustache` file will inherit the `size` and `start` variables from the calling context. In this way you may want to think of partials as includes, imports, template expansion, nested templates, or subtemplates, even though those aren't literally the case here.
 
 
-## Streaming
+For example, this template and partial:
 
-To stream template results out of mustache.js, you can pass an optional
-`send()` callback to the `to_html()` call:
+    base.mustache:
+    <h2>Names</h2>
+    {{#names}}
+      {{> user}}
+    {{/names}}
 
-    Mustache.to_html(template, view, partials, function(line) {
-      print(line);
-    });
+    user.mustache:
+    <strong>{{name}}</strong>
 
+Can be thought of as a single, expanded template:
 
-## Pragmas
+```html
+<h2>Names</h2>
+{{#names}}
+  <strong>{{name}}</strong>
+{{/names}}
+```
 
-Pragma tags let you alter the behaviour of mustache.js. They have the format
-of
+In mustache.js an object of partials may be passed as the third argument to `Mustache.render`. The object should be keyed by the name of the partial, and its value should be the partial text.
 
-    {{%PRAGMANAME}}
+```js
+Mustache.render(template, view, {
+  user: userTemplate
+});
+```
 
-and they accept options:
+### Custom Delimiters
 
-    {{%PRAGMANAME option=value}}
+Custom delimiters can be used in place of `{{` and `}}` by setting the new values in JavaScript or in templates.
 
+#### Setting in JavaScript
 
-### IMPLICIT-ITERATOR
+The `Mustache.tags` property holds an array consisting of the opening and closing tag values. Set custom values by passing a new array of tags to `parse()`, which gets honored over the default values, or by overriding the `tags` property itself:
 
-When using a block to iterate over an enumerable (Array), mustache.js expects
-an objects as enumerable items. The implicit iterator pragma enables optional
-behaviour of allowing literals as enumerable items. Consider this view:
+```js
+var customTags = [ '<%', '%>' ];
+```
 
-    var view = {
-      foo: [1, 2, 3, 4, 5, "french"]
-    };
+##### Pass Value into Parse Method
+```js
+Mustache.parse(template, customTags);
+```
 
-The following template can iterate over the member `foo`:
+##### Override Tags Property
+```js
+Mustache.tags = customTags;
+// Subsequent parse() and render() calls will use customTags
+```
 
-    {{%IMPLICIT-ITERATOR}}
-    {{#foo}}
-      {{.}}
-    {{/foo}}
+#### Setting in Templates
 
-If you don't like the dot in there, the pragma accepts an option to set your
-own iteration marker:
+Set Delimiter tags start with an equals sign and change the tag delimiters from `{{` and `}}` to custom strings.
 
-    {{%IMPLICIT-ITERATOR iterator=bob}}
-    {{#foo}}
-      {{bob}}
-    {{/foo}}
+Consider the following contrived example:
+
+```html+erb
+* {{ default_tags }}
+{{=<% %>=}}
+* <% erb_style_tags %>
+<%={{ }}=%>
+* {{ default_tags_again }}
+```
+
+Here we have a list with three items. The first item uses the default tag style, the second uses ERB style as defined by the Set Delimiter tag, and the third returns to the default style after yet another Set Delimiter declaration.
+
+According to [ctemplates](https://htmlpreview.github.io/?https://raw.githubusercontent.com/OlafvdSpek/ctemplate/master/doc/howto.html), this "is useful for languages like TeX, where double-braces may occur in the text and are awkward to use for markup."
+
+Custom delimiters may not contain whitespace or the equals sign.
+
+## Pre-parsing and Caching Templates
+
+By default, when mustache.js first parses a template it keeps the full parsed token tree in a cache. The next time it sees that same template it skips the parsing step and renders the template much more quickly. If you'd like, you can do this ahead of time using `mustache.parse`.
+
+```js
+Mustache.parse(template);
+
+// Then, sometime later.
+Mustache.render(template, view);
+```
 
 ## Plugins for JavaScript Libraries
 
-mustache.js may be built specifically for several different client libraries
-and platforms, including the following:
+mustache.js may be built specifically for several different client libraries, including the following:
 
-  - [node](http://nodejs.org/) (or other CommonJS platforms)
   - [jQuery](http://jquery.com/)
+  - [MooTools](http://mootools.net/)
   - [Dojo](http://www.dojotoolkit.org/)
   - [YUI](http://developer.yahoo.com/yui/)
-  - [RequireJS](http://requirejs.org/)
   - [qooxdoo](http://qooxdoo.org/)
 
-These may be built using [Rake](http://rake.rubyforge.org/) and one of the
-following commands:
-
-    $ rake commonjs
-    $ rake jquery
-    $ rake dojo
-    $ rake yui
-    $ rake requirejs
-    $ rake qooxdoo
-
+These may be built using [Rake](http://rake.rubyforge.org/) and one of the following commands:
+```bash
+$ rake jquery
+$ rake mootools
+$ rake dojo
+$ rake yui3
+$ rake qooxdoo
+```
+## Testing
+
+In order to run the tests you'll need to install [node](http://nodejs.org/).
+
+You also need to install the sub module containing [Mustache specifications](http://github.com/mustache/spec) in the project root.
+```bash
+$ git submodule init
+$ git submodule update
+```
+Install dependencies.
+```bash
+$ npm install
+```
+Then run the tests.
+```bash
+$ npm test
+```
+The test suite consists of both unit and integration tests. If a template isn't rendering correctly for you, you can make a test for it by doing the following:
+
+  1. Create a template file named `mytest.mustache` in the `test/_files`
+     directory. Replace `mytest` with the name of your test.
+  2. Create a corresponding view file named `mytest.js` in the same directory.
+     This file should contain a JavaScript object literal enclosed in
+     parentheses. See any of the other view files for an example.
+  3. Create a file with the expected output in `mytest.txt` in the same
+     directory.
+
+Then, you can run the test with:
+```bash
+$ TEST=mytest npm run test-render
+```
+### Browser tests
+
+Browser tests are not included in `npm test` as they run for too long, although they are ran automatically on Travis when merged into master. Run browser tests locally in any browser:
+```bash
+$ npm run test-browser-local
+```
+then point your browser to `http://localhost:8080/__zuul`
+
+### Troubleshooting
+
+#### npm install fails
+
+Ensure to have a recent version of npm installed. While developing this project requires npm with support for `^` version ranges.
+```bash
+$ npm install -g npm
+```
 ## Thanks
 
-Mustache.js wouldn't kick ass if it weren't for these fine souls:
+mustache.js wouldn't kick ass if it weren't for these fine souls:
 
   * Chris Wanstrath / defunkt
   * Alexander Lang / langalex
@@ -316,4 +634,6 @@ Mustache.js wouldn't kick ass if it weren't for these fine souls:
   * Ross Boucher / boucher
   * Matt Sanford / mzsanford
   * Ben Cherry / bcherry
-  * Michael Jackson / mjijackson
+  * Michael Jackson / mjackson
+  * Phillip Johnsen / phillipj
+  * David da Silva Contín / dasilvacontin
diff --git a/Rakefile b/Rakefile
index f546b74..c019087 100644
--- a/Rakefile
+++ b/Rakefile
@@ -1,62 +1,69 @@
 require 'rake'
 require 'rake/clean'
 
-task :default => :spec
-
-desc "Run all specs"
-task :spec do
-  require 'rspec/core/rake_task'
-  RSpec::Core::RakeTask.new(:spec) do |t|
-    #t.spec_opts = ['--options', "\"#{File.dirname(__FILE__)}/spec/spec.opts\""]
-    t.pattern = 'spec/*_spec.rb'
-  end
+task :default => :test
+
+def minified_file
+  ENV['FILE'] || 'mustache.min.js'
+end
+
+task :install_mocha do
+  sh "npm install -g mocha" if `which mocha`.empty?
+end
+
+task :install_uglify do
+  sh "npm install -g uglify-js" if `which uglifyjs`.empty?
+end
+
+task :install_jshint do
+  sh "npm install -g jshint" if `which jshint`.empty?
 end
 
-def version
-  File.read("mustache.js").match('version: "([^\"]+)",$')[1]
+desc "Run all tests"
+task :test => :install_mocha do
+  sh "mocha test"
 end
 
-# Creates 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.
-def templated_build(name, opts={})
+desc "Make a compressed build in #{minified_file}"
+task :minify => :install_uglify do
+  sh "uglifyjs mustache.js > #{minified_file}"
+end
+
+desc "Run JSHint"
+task :hint => :install_jshint do
+  sh "jshint mustache.js"
+end
+
+# Creates a task that uses the various template wrappers to make a wrapped
+# output file. There is some extra complexity because Dojo and YUI use
+# different final locations.
+def templated_build(name, final_location=nil)
   short = name.downcase
   source = File.join("wrappers", short)
   dependencies = ["mustache.js"] + Dir.glob("#{source}/*.tpl.*")
-  target_js = opts[:location] ? "mustache.js" : "#{short}.mustache.js"
-
-  CLEAN.include(opts[:location] ? opts[:location] : target_js)
+  target_js = final_location.nil? ? "#{short}.mustache.js" : "mustache.js"
 
   desc "Package for #{name}"
   task short.to_sym => dependencies do
     puts "Packaging for #{name}"
 
-    mkdir_p opts[:location] if opts[:location]
+    mkdir_p final_location unless final_location.nil?
 
-    sh "cat #{source}/#{target_js}.tpl.pre mustache.js \
-      #{source}/#{target_js}.tpl.post > #{opts[:location] || '.'}/#{target_js}"
+    sources = [ "#{source}/mustache.js.pre", 'mustache.js', "#{source}/mustache.js.post" ]
+    relative_name = "#{final_location || '.'}/#{target_js}"
 
-    # extra
-    if opts[:extra]
-      sh "sed -e 's/{{version}}/#{version}/' #{source}/#{opts[:extra]} \
-        > #{opts[:location]}/#{opts[:extra]}"
+    open(relative_name, 'w') do |f|
+      sources.each {|source| f << File.read(source) }
     end
 
-    puts "Done, see #{opts[:location] || '.'}/#{target_js}"
+    puts "Done, see #{relative_name}"
   end
+
+  CLEAN.include(final_location.nil? ? target_js : final_location)
 end
 
-templated_build "CommonJS", :location => "lib", :extra => "package.json"
 templated_build "jQuery"
-templated_build "Dojo", :location => "dojox/string"
-templated_build "YUI3", :location => "yui3/mustache"
-templated_build "RequireJS"
+templated_build "MooTools"
+templated_build "Dojo", "dojox/string"
+templated_build "YUI3", "yui3/mustache"
 templated_build "qooxdoo"
-
-task :minify do
-  # npm install uglify-js
-  mmjs = "mustache.min.js"
-  `echo "/*! Version: 0.4.2 */" > #{mmjs}`
-  `uglifyjs mustache.js >> #{mmjs}`
-  puts "Created #{mmjs}"
-end
diff --git a/TESTING.md b/TESTING.md
deleted file mode 100644
index 0be439b..0000000
--- a/TESTING.md
+++ /dev/null
@@ -1,75 +0,0 @@
-## Running the mustache.js Test Suite
-
-Notice: the tests are only expected to run on unixoid systems.
-
-The mustache.js test suite uses the [RSpec](http://rspec.info/) testing
-framework. In order to run the tests you'll need to install [Ruby](http://ruby-lang.org/)
-as well as the `rake`, `rspec` (>=2), and `json` [RubyGems](http://rubygems.org/).
-
-### How to install Ruby and the required gems from source
-
-Make sure you have the required tools to compile it:
-
-    $ apt-get install build-essential libssl-dev libreadline5-dev zlib1g-dev
-
-Download and extract the Ruby source, and install it:
-
-    $ wget ftp://ftp.ruby-lang.org/pub/ruby/stable-snapshot.tar.gz
-    $ tar xvzf stable-snapshot.tar.gz
-    $ cd ruby
-    $ ./configure && make && make install
-
-Download and extract RubyGems, and install it:
-
-    $ wget http://production.cf.rubygems.org/rubygems/rubygems-1.8.12.tgz
-    $ tar xzvf rubygems-1.8.12.tgz
-    $ cd rubygems-1.8.12
-    $ ruby setup.rb
-
-If you want to update RubyGems:
-
-    $ gem update --system
-
-Install the required gems:
-
-    $ gem install rake rspec json
-
-That's it!
-
-### How to install node.js from source
-
-    $ git clone https://github.com/joyent/node.git
-    $ cd node
-    $ # select the version to install, master is unstable;
-    $ # latest stable version is advertised on http://nodejs.org
-    $ git checkout v0.6.11
-    $ ./configure
-    $ make
-    $ sudo make install
-
-### How to run the tests
-
-The mustache.js test suite currently uses 4 different JavaScript runtime engines
-to maximize portability across platforms and browsers. They are:
-
-  * node
-  * SpiderMonkey (Mozilla, Firefox)
-  * JavaScriptCore (WebKit, Safari)
-  * Rhino (Mozilla, Java)
-
-When the test suite runs it will automatically determine which platforms are
-available on your machine and run on all of them. The suite must run on at least
-one platform in order to succeed.
-
-Once you have at least one JavaScript platform installed, you can run the test
-suite with the following command:
-
-    $ rake
-
-### How to create a test
-
-All test files live in the spec/_files directory. To create a new test:
-
-  * Create a template file `somename.mustache`
-  * Create a javascript file with data and functions `somename.js`
-  * Create a file the expected result `somename.txt`
diff --git a/bin/mustache b/bin/mustache
new file mode 100755
index 0000000..430e8b9
--- /dev/null
+++ b/bin/mustache
@@ -0,0 +1,136 @@
+#!/usr/bin/env node
+
+var fs = require('fs'),
+    path = require('path');
+
+var Mustache = require('..');
+var pkg = require('../package');
+var partials = {};
+
+var partialsPaths = [];
+var partialArgIndex = -1;
+
+while ((partialArgIndex = process.argv.indexOf('-p')) > -1) {
+  partialsPaths.push(process.argv.splice(partialArgIndex, 2)[1]);
+}
+
+var viewArg = process.argv[2];
+var templateArg = process.argv[3];
+var outputArg = process.argv[4];
+
+if (hasVersionArg()) {
+  return console.log(pkg.version);
+}
+
+if (!templateArg || !viewArg) {
+  console.error('Syntax: mustache <view> <template> [output]');
+  process.exit(1);
+}
+
+run(readPartials, readView, readTemplate, render, toStdout);
+
+/**
+ * Runs a list of functions as a waterfall.
+ * Functions are runned one after the other in order, providing each
+ * function the returned values of all the previously invoked functions.
+ * Each function is expected to exit the process if an error occurs.
+ */
+function run (/*args*/) {
+  var values = [];
+  var fns = Array.prototype.slice.call(arguments);
+
+  function invokeNextFn (val) {
+    values.unshift(val);
+    if (fns.length === 0) return;
+    invoke(fns.shift());
+  }
+
+  function invoke (fn) {
+    fn.apply(null, [invokeNextFn].concat(values));
+  }
+
+  invoke(fns.shift());
+}
+
+function readView (cb) {
+  var view = isStdin(viewArg) ? process.openStdin() : fs.createReadStream(viewArg);
+
+  streamToStr(view, function onDone (str) {
+    cb(parseView(str));
+  });
+}
+
+function parseView (str) {
+  try {
+    return JSON.parse(str);
+  } catch (ex) {
+    console.error(
+      'Shooot, could not parse view as JSON.\n' +
+      'Tips: functions are not valid JSON and keys / values must be surround with double quotes.\n\n' +
+      ex.stack);
+
+    process.exit(1);
+  }
+}
+
+function readPartials (cb) {
+  if (!partialsPaths.length) return cb();
+  var partialPath = partialsPaths.pop();
+  var partial = fs.createReadStream(partialPath);
+  streamToStr(partial, function onDone (str) {
+    partials[getPartialName(partialPath)] = str;
+    readPartials(cb);
+  });
+}
+
+function readTemplate (cb) {
+  var template = fs.createReadStream(templateArg);
+  streamToStr(template, cb);
+}
+
+function render (cb, templateStr, jsonView) {
+  cb(Mustache.render(templateStr, jsonView, partials));
+}
+
+function toStdout (cb, str) {
+  if (outputArg) {
+    cb(fs.writeFileSync(outputArg, str));
+  } else {
+    cb(process.stdout.write(str));
+  }
+}
+
+function streamToStr (stream, cb) {
+  var data = '';
+
+  stream.on('data', function onData (chunk) {
+    data += chunk;
+  }).once('end', function onEnd () {
+    cb(data.toString());
+  }).on('error', function onError (err) {
+    if (wasNotFound(err)) {
+      console.error('Could not find file:', err.path);
+    } else {
+      console.error('Error while reading file:', err.message);
+    }
+    process.exit(1);
+  });
+}
+
+function isStdin (view) {
+  return view === '-';
+}
+
+function wasNotFound (err) {
+  return err.code && err.code === 'ENOENT';
+}
+
+function hasVersionArg () {
+  return ['--version', '-v'].some(function matchInArgs (opt) {
+    return process.argv.indexOf(opt) > -1;
+  });
+}
+
+function getPartialName (filename) {
+  return path.basename(filename, '.mustache');
+}
diff --git a/bower.json b/bower.json
new file mode 100644
index 0000000..3a92948
--- /dev/null
+++ b/bower.json
@@ -0,0 +1,20 @@
+{
+  "name": "mustache.js",
+  "main": "mustache.js",
+  "homepage": "https://github.com/janl/mustache.js",
+  "authors": [
+    "mustache.js Authors <http://github.com/janl/mustache.js>"
+  ],
+  "description": "Logic-less {{mustache}} templates with JavaScript",
+  "keywords": ["mustache", "template", "templates", "ejs"],
+  "moduleType": [
+    "amd",
+    "globals",
+    "node"
+  ],
+  "license": "MIT",
+  "ignore": [
+    "**/.*",
+    "test"
+  ]
+}
diff --git a/hooks/install-hooks.sh b/hooks/install-hooks.sh
new file mode 100755
index 0000000..422d24d
--- /dev/null
+++ b/hooks/install-hooks.sh
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+HOOK_NAMES="pre-commit"
+HOOK_DIR=$(git rev-parse --show-toplevel)/.git/hooks
+INSTALL_DIR=$(git rev-parse --show-toplevel)/hooks
+COLOR_GREEN=`tput setaf 2`
+COLOR_RESET=`tput sgr0`
+
+for hook in $HOOK_NAMES; do
+    echo -n "Installing $hook hook..."
+    # If the hook already exists, is executable, and is not a symlink
+    if [ ! -h $HOOK_DIR/$hook -a -x $HOOK_DIR/$hook ]; then
+        echo -n " Hook already exists, saving old hook backup at $HOOK_DIR/$hook.local..."
+        mv $HOOK_DIR/$hook $HOOK_DIR/$hook.local
+    fi
+    # create the symlink, overwriting the file if it exists
+    # probably the only way this would happen is if you're using an old version of git
+    # -- back when the sample hooks were not executable, instead of being named ____.sample
+    echo -n " Creating symlink..."
+    ln -s -f $INSTALL_DIR/$hook $HOOK_DIR
+    echo "${COLOR_GREEN} Done! ✓${COLOR_RESET}"
+done
\ No newline at end of file
diff --git a/hooks/pre-commit b/hooks/pre-commit
new file mode 100755
index 0000000..7b75dd3
--- /dev/null
+++ b/hooks/pre-commit
@@ -0,0 +1,89 @@
+#!/usr/bin/env ruby
+
+require 'json'
+
+def puts_c(color, str)
+	puts "\x1b[#{color}m#{str}\x1b[0m"
+end
+
+class Source
+	attr_accessor :path, :v_regex
+
+	def initialize(path, v_regex)
+		@path = path
+		@v_regex = v_regex
+	end
+end
+
+class Bumper
+	attr_accessor :sources, :bumped, :target_v
+
+	def initialize(sources)
+		@sources = sources
+	end
+
+	def start
+
+		# get package.json version
+		package = JSON.parse File.read 'package.json'
+		@target_v = package['version']
+
+		@bumped = false
+		@sources.each {|source| bump_source(source)}
+
+		# if bumped, do extra stuff and notify the user
+		if @bumped
+
+			# minify `mustache.js` using the Rakefile task
+			puts "> minifying `mustache.js`..."
+			`rake minify`
+
+			# stage files for commit
+			`git add package.json`
+			@sources.each {|source| `git add #{source.path}`}
+			`git add mustache.min.js`
+			`git commit -m ":ship: bump to version #{@target_v}"`
+
+			# notify codemonkey
+			puts "staged bumped files and created commit"
+			puts_c 32, "successfully bumped version to #{@target_v}!"
+			puts_c 33, "don't forget to `npm publish` and `spm publish`!"
+		end
+
+		exit 0
+	end
+
+	def bump_source(source)
+		file_buffer = File.read source.path
+		if match = file_buffer.match(source.v_regex)
+			file_v = match.captures[0]
+			if @target_v != file_v
+				did_bump
+				puts "> bumping version in file '#{source.path}': #{file_v} -> #{@target_v}..."
+				file_buffer[source.v_regex, 1] = @target_v
+				File.open(source.path, 'w') { |f| f.write file_buffer }
+			end
+		else
+			puts_c 31, "ERROR: Can't find version in '#{source.path}'"
+			exit 1
+		end
+	end
+
+	def did_bump
+		if !@bumped
+			puts 'bump detected!'
+			if `which uglifyjs`.empty?
+				puts_c 31, 'you need uglifyjs installed'
+				puts 'run `sudo npm install -g uglify-js`'
+				exit 1
+			end
+		end
+		@bumped = true
+	end
+end
+
+bumper = Bumper.new([
+	Source.new('mustache.js', /mustache.version = '([\d\.]*)'/),
+	Source.new('mustache.js.nuspec', /<version>([\d\.]*)<\/version>/),
+])
+bumper.start
diff --git a/mustache.js b/mustache.js
index 4ac3fae..5ffdfe6 100644
--- a/mustache.js
+++ b/mustache.js
@@ -1,436 +1,630 @@
-/*
-  mustache.js — Logic-less templates in JavaScript
+/*!
+ * mustache.js - Logic-less {{mustache}} templates with JavaScript
+ * http://github.com/janl/mustache.js
+ */
+
+/*global define: false Mustache: true*/
+
+(function defineMustache (global, factory) {
+  if (typeof exports === 'object' && exports && typeof exports.nodeName !== 'string') {
+    factory(exports); // CommonJS
+  } else if (typeof define === 'function' && define.amd) {
+    define(['exports'], factory); // AMD
+  } else {
+    global.Mustache = {};
+    factory(global.Mustache); // script, wsh, asp
+  }
+}(this, function mustacheFactory (mustache) {
 
-  See http://mustache.github.com/ for more info.
-*/
+  var objectToString = Object.prototype.toString;
+  var isArray = Array.isArray || function isArrayPolyfill (object) {
+    return objectToString.call(object) === '[object Array]';
+  };
 
-var Mustache = function () {
-  var _toString = Object.prototype.toString;
+  function isFunction (object) {
+    return typeof object === 'function';
+  }
 
-  Array.isArray = Array.isArray || function (obj) {
-    return _toString.call(obj) == "[object Array]";
+  /**
+   * More correct typeof string handling array
+   * which normally returns typeof 'object'
+   */
+  function typeStr (obj) {
+    return isArray(obj) ? 'array' : typeof obj;
   }
 
-  var _trim = String.prototype.trim, trim;
+  function escapeRegExp (string) {
+    return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, '\\$&');
+  }
 
-  if (_trim) {
-    trim = function (text) {
-      return text == null ? "" : _trim.call(text);
-    }
-  } else {
-    var trimLeft, trimRight;
+  /**
+   * Null safe way of checking whether or not an object,
+   * including its prototype, has a given property
+   */
+  function hasProperty (obj, propName) {
+    return obj != null && typeof obj === 'object' && (propName in obj);
+  }
 
-    // IE doesn't match non-breaking spaces with \s.
-    if ((/\S/).test("\xA0")) {
-      trimLeft = /^[\s\xA0]+/;
-      trimRight = /[\s\xA0]+$/;
-    } else {
-      trimLeft = /^\s+/;
-      trimRight = /\s+$/;
-    }
+  // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577
+  // See https://github.com/janl/mustache.js/issues/189
+  var regExpTest = RegExp.prototype.test;
+  function testRegExp (re, string) {
+    return regExpTest.call(re, string);
+  }
 
-    trim = function (text) {
-      return text == null ? "" :
-        text.toString().replace(trimLeft, "").replace(trimRight, "");
-    }
+  var nonSpaceRe = /\S/;
+  function isWhitespace (string) {
+    return !testRegExp(nonSpaceRe, string);
   }
 
-  var escapeMap = {
-    "&": "&",
-    "<": "<",
-    ">": ">",
+  var entityMap = {
+    '&': '&',
+    '<': '<',
+    '>': '>',
     '"': '"',
-    "'": '''
+    "'": ''',
+    '/': '&#x2F;',
+    '`': '&#x60;',
+    '=': '&#x3D;'
   };
 
-  function escapeHTML(string) {
-    return String(string).replace(/&(?!#?\w+;)|[<>"']/g, function (s) {
-      return escapeMap[s] || s;
+  function escapeHtml (string) {
+    return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) {
+      return entityMap[s];
     });
   }
 
-  var regexCache = {};
-  var Renderer = function () {};
-
-  Renderer.prototype = {
-    otag: "{{",
-    ctag: "}}",
-    pragmas: {},
-    buffer: [],
-    pragmas_implemented: {
-      "IMPLICIT-ITERATOR": true
-    },
-    context: {},
-
-    render: function (template, context, partials, in_recursion) {
-      // reset buffer & set context
-      if (!in_recursion) {
-        this.context = context;
-        this.buffer = []; // TODO: make this non-lazy
+  var whiteRe = /\s*/;
+  var spaceRe = /\s+/;
+  var equalsRe = /\s*=/;
+  var curlyRe = /\s*\}/;
+  var tagRe = /#|\^|\/|>|\{|&|=|!/;
+
+  /**
+   * Breaks up the given `template` string into a tree of tokens. If the `tags`
+   * argument is given here it must be an array with two string values: the
+   * opening and closing tags used in the template (e.g. [ "<%", "%>" ]). Of
+   * course, the default is to use mustaches (i.e. mustache.tags).
+   *
+   * A token is an array with at least 4 elements. The first element is the
+   * mustache symbol that was used inside the tag, e.g. "#" or "&". If the tag
+   * did not contain a symbol (i.e. {{myValue}}) this element is "name". For
+   * all text that appears outside a symbol this element is "text".
+   *
+   * The second element of a token is its "value". For mustache tags this is
+   * whatever else was inside the tag besides the opening symbol. For text tokens
+   * this is the text itself.
+   *
+   * The third and fourth elements of the token are the start and end indices,
+   * respectively, of the token in the original template.
+   *
+   * Tokens that are the root node of a subtree contain two more elements: 1) an
+   * array of tokens in the subtree and 2) the index in the original template at
+   * which the closing tag for that section begins.
+   */
+  function parseTemplate (template, tags) {
+    if (!template)
+      return [];
+
+    var sections = [];     // Stack to hold section tokens
+    var tokens = [];       // Buffer to hold the tokens
+    var spaces = [];       // Indices of whitespace tokens on the current line
+    var hasTag = false;    // Is there a {{tag}} on the current line?
+    var nonSpace = false;  // Is there a non-space char on the current line?
+
+    // Strips all whitespace tokens array for the current line
+    // if there was a {{#tag}} on it and otherwise only space.
+    function stripSpace () {
+      if (hasTag && !nonSpace) {
+        while (spaces.length)
+          delete tokens[spaces.pop()];
+      } else {
+        spaces = [];
       }
 
-      // fail fast
-      if (!this.includes("", template)) {
-        if (in_recursion) {
-          return template;
-        } else {
-          this.send(template);
-          return;
-        }
-      }
+      hasTag = false;
+      nonSpace = false;
+    }
+
+    var openingTagRe, closingTagRe, closingCurlyRe;
+    function compileTags (tagsToCompile) {
+      if (typeof tagsToCompile === 'string')
+        tagsToCompile = tagsToCompile.split(spaceRe, 2);
+
+      if (!isArray(tagsToCompile) || tagsToCompile.length !== 2)
+        throw new Error('Invalid tags: ' + tagsToCompile);
+
+      openingTagRe = new RegExp(escapeRegExp(tagsToCompile[0]) + '\\s*');
+      closingTagRe = new RegExp('\\s*' + escapeRegExp(tagsToCompile[1]));
+      closingCurlyRe = new RegExp('\\s*' + escapeRegExp('}' + tagsToCompile[1]));
+    }
+
+    compileTags(tags || mustache.tags);
+
+    var scanner = new Scanner(template);
+
+    var start, type, value, chr, token, openSection;
+    while (!scanner.eos()) {
+      start = scanner.pos;
 
-      // get the pragmas together
-      template = this.render_pragmas(template);
+      // Match any text between tags.
+      value = scanner.scanUntil(openingTagRe);
 
-      // render the template
-      var html = this.render_section(template, context, partials);
+      if (value) {
+        for (var i = 0, valueLength = value.length; i < valueLength; ++i) {
+          chr = value.charAt(i);
 
-      // render_section did not find any sections, we still need to render the tags
-      if (html === false) {
-        html = this.render_tags(template, context, partials, in_recursion);
+          if (isWhitespace(chr)) {
+            spaces.push(tokens.length);
+          } else {
+            nonSpace = true;
+          }
+
+          tokens.push([ 'text', chr, start, start + 1 ]);
+          start += 1;
+
+          // Check for whitespace on the current line.
+          if (chr === '\n')
+            stripSpace();
+        }
       }
 
-      if (in_recursion) {
-        return html;
+      // Match the opening tag.
+      if (!scanner.scan(openingTagRe))
+        break;
+
+      hasTag = true;
+
+      // Get the tag type.
+      type = scanner.scan(tagRe) || 'name';
+      scanner.scan(whiteRe);
+
+      // Get the tag value.
+      if (type === '=') {
+        value = scanner.scanUntil(equalsRe);
+        scanner.scan(equalsRe);
+        scanner.scanUntil(closingTagRe);
+      } else if (type === '{') {
+        value = scanner.scanUntil(closingCurlyRe);
+        scanner.scan(curlyRe);
+        scanner.scanUntil(closingTagRe);
+        type = '&';
       } else {
-        this.sendLines(html);
-      }
-    },
-
-    /*
-      Sends parsed lines
-    */
-    send: function (line) {
-      if (line !== "") {
-        this.buffer.push(line);
+        value = scanner.scanUntil(closingTagRe);
       }
-    },
 
-    sendLines: function (text) {
-      if (text) {
-        var lines = text.split("\n");
-        for (var i = 0; i < lines.length; i++) {
-          this.send(lines[i]);
-        }
-      }
-    },
-
-    /*
-      Looks for %PRAGMAS
-    */
-    render_pragmas: function (template) {
-      // no pragmas
-      if (!this.includes("%", template)) {
-        return template;
+      // Match the closing tag.
+      if (!scanner.scan(closingTagRe))
+        throw new Error('Unclosed tag at ' + scanner.pos);
+
+      token = [ type, value, start, scanner.pos ];
+      tokens.push(token);
+
+      if (type === '#' || type === '^') {
+        sections.push(token);
+      } else if (type === '/') {
+        // Check section nesting.
+        openSection = sections.pop();
+
+        if (!openSection)
+          throw new Error('Unopened section "' + value + '" at ' + start);
+
+        if (openSection[1] !== value)
+          throw new Error('Unclosed section "' + openSection[1] + '" at ' + start);
+      } else if (type === 'name' || type === '{' || type === '&') {
+        nonSpace = true;
+      } else if (type === '=') {
+        // Set the tags for the next time around.
+        compileTags(value);
       }
+    }
 
-      var that = this;
-      var regex = this.getCachedRegex("render_pragmas", function (otag, ctag) {
-        return new RegExp(otag + "%([\\w-]+) ?([\\w]+=[\\w]+)?" + ctag, "g");
-      });
+    // Make sure there are no open sections when we're done.
+    openSection = sections.pop();
 
-      return template.replace(regex, function (match, pragma, options) {
-        if (!that.pragmas_implemented[pragma]) {
-          throw({message:
-            "This implementation of mustache doesn't understand the '" +
-            pragma + "' pragma"});
-        }
-        that.pragmas[pragma] = {};
-        if (options) {
-          var opts = options.split("=");
-          that.pragmas[pragma][opts[0]] = opts[1];
+    if (openSection)
+      throw new Error('Unclosed section "' + openSection[1] + '" at ' + scanner.pos);
+
+    return nestTokens(squashTokens(tokens));
+  }
+
+  /**
+   * Combines the values of consecutive text tokens in the given `tokens` array
+   * to a single token.
+   */
+  function squashTokens (tokens) {
+    var squashedTokens = [];
+
+    var token, lastToken;
+    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
+      token = tokens[i];
+
+      if (token) {
+        if (token[0] === 'text' && lastToken && lastToken[0] === 'text') {
+          lastToken[1] += token[1];
+          lastToken[3] = token[3];
+        } else {
+          squashedTokens.push(token);
+          lastToken = token;
         }
-        return "";
-        // ignore unknown pragmas silently
-      });
-    },
-
-    /*
-      Tries to find a partial in the curent scope and render it
-    */
-    render_partial: function (name, context, partials) {
-      name = trim(name);
-      if (!partials || partials[name] === undefined) {
-        throw({message: "unknown_partial '" + name + "'"});
       }
-      if (!context || typeof context[name] != "object") {
-        return this.render(partials[name], context, partials, true);
-      }
-      return this.render(partials[name], context[name], partials, true);
-    },
-
-    /*
-      Renders inverted (^) and normal (#) sections
-    */
-    render_section: function (template, context, partials) {
-      if (!this.includes("#", template) && !this.includes("^", template)) {
-        // did not render anything, there were no sections
-        return false;
+    }
+
+    return squashedTokens;
+  }
+
+  /**
+   * Forms the given array of `tokens` into a nested tree structure where
+   * tokens that represent a section have two additional items: 1) an array of
+   * all tokens that appear in that section and 2) the index in the original
+   * template that represents the end of that section.
+   */
+  function nestTokens (tokens) {
+    var nestedTokens = [];
+    var collector = nestedTokens;
+    var sections = [];
+
+    var token, section;
+    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
+      token = tokens[i];
+
+      switch (token[0]) {
+        case '#':
+        case '^':
+          collector.push(token);
+          sections.push(token);
+          collector = token[4] = [];
+          break;
+        case '/':
+          section = sections.pop();
+          section[5] = token[2];
+          collector = sections.length > 0 ? sections[sections.length - 1][4] : nestedTokens;
+          break;
+        default:
+          collector.push(token);
       }
+    }
+
+    return nestedTokens;
+  }
+
+  /**
+   * A simple string scanner that is used by the template parser to find
+   * tokens in template strings.
+   */
+  function Scanner (string) {
+    this.string = string;
+    this.tail = string;
+    this.pos = 0;
+  }
 
-      var that = this;
+  /**
+   * Returns `true` if the tail is empty (end of string).
+   */
+  Scanner.prototype.eos = function eos () {
+    return this.tail === '';
+  };
 
-      var regex = this.getCachedRegex("render_section", function (otag, ctag) {
-        // This regex matches _the first_ section ({{#foo}}{{/foo}}), and captures the remainder
-        return new RegExp(
-          "^([\\s\\S]*?)" +         // all the crap at the beginning that is not {{*}} ($1)
+  /**
+   * Tries to match the given regular expression at the current position.
+   * Returns the matched text if it can match, the empty string otherwise.
+   */
+  Scanner.prototype.scan = function scan (re) {
+    var match = this.tail.match(re);
 
-          otag +                    // {{
-          "(\\^|\\#)\\s*(.+?)\\s*" +//  #foo (# == $2, foo == $3), not greedy
-          ctag +                    // }}
+    if (!match || match.index !== 0)
+      return '';
 
-          "\n*([\\s\\S]*?)" +       // between the tag ($2). leading newlines are dropped
+    var string = match[0];
 
-          otag +                    // {{
-          "\\/\\s*\\3\\s*" +        //  /foo (backreference to the opening tag).
-          ctag +                    // }}
+    this.tail = this.tail.substring(string.length);
+    this.pos += string.length;
 
-          "\\s*([\\s\\S]*)$",       // everything else in the string ($4). leading whitespace is dropped.
+    return string;
+  };
 
-        "g");
-      });
+  /**
+   * Skips all text until the given regular expression can be matched. Returns
+   * the skipped string, which is the entire tail if no match can be made.
+   */
+  Scanner.prototype.scanUntil = function scanUntil (re) {
+    var index = this.tail.search(re), match;
+
+    switch (index) {
+      case -1:
+        match = this.tail;
+        this.tail = '';
+        break;
+      case 0:
+        match = '';
+        break;
+      default:
+        match = this.tail.substring(0, index);
+        this.tail = this.tail.substring(index);
+    }
 
+    this.pos += match.length;
 
-      // for each {{#foo}}{{/foo}} section do...
-      return template.replace(regex, function (match, before, type, name, content, after) {
-        // before contains only tags, no sections
-        var renderedBefore = before ? that.render_tags(before, context, partials, true) : "",
+    return match;
+  };
 
-        // after may contain both sections and tags, so use full rendering function
-            renderedAfter = after ? that.render(after, context, partials, true) : "",
+  /**
+   * Represents a rendering context by wrapping a view object and
+   * maintaining a reference to the parent context.
+   */
+  function Context (view, parentContext) {
+    this.view = view;
+    this.cache = { '.': this.view };
+    this.parent = parentContext;
+  }
 
-        // will be computed below
-            renderedContent,
+  /**
+   * Creates a new context using the given view with this context
+   * as the parent.
+   */
+  Context.prototype.push = function push (view) {
+    return new Context(view, this);
+  };
 
-            value = that.find(name, context);
+  /**
+   * Returns the value of the given name in this context, traversing
+   * up the context hierarchy if the value is absent in this context's view.
+   */
+  Context.prototype.lookup = function lookup (name) {
+    var cache = this.cache;
 
-        if (type === "^") { // inverted section
-          if (!value || Array.isArray(value) && value.length === 0) {
-            // false or empty list, render it
-            renderedContent = that.render(content, context, partials, true);
-          } else {
-            renderedContent = "";
-          }
-        } else if (type === "#") { // normal section
-          if (Array.isArray(value)) { // Enumerable, Let's loop!
-            renderedContent = that.map(value, function (row) {
-              return that.render(content, that.create_context(row), partials, true);
-            }).join("");
-          } else if (that.is_object(value)) { // Object, Use it as subcontext!
-            renderedContent = that.render(content, that.create_context(value),
-              partials, true);
-          } else if (typeof value == "function") {
-            // higher order section
-            renderedContent = value.call(context, content, function (text) {
-              return that.render(text, context, partials, true);
-            });
-          } else if (value) { // boolean section
-            renderedContent = that.render(content, context, partials, true);
-          } else {
-            renderedContent = "";
+    var value;
+    if (cache.hasOwnProperty(name)) {
+      value = cache[name];
+    } else {
+      var context = this, names, index, lookupHit = false;
+
+      while (context) {
+        if (name.indexOf('.') > 0) {
+          value = context.view;
+          names = name.split('.');
+          index = 0;
+
+          /**
+           * Using the dot notion path in `name`, we descend through the
+           * nested objects.
+           *
+           * To be certain that the lookup has been successful, we have to
+           * check if the last object in the path actually has the property
+           * we are looking for. We store the result in `lookupHit`.
+           *
+           * This is specially necessary for when the value has been set to
+           * `undefined` and we want to avoid looking up parent contexts.
+           **/
+          while (value != null && index < names.length) {
+            if (index === names.length - 1)
+              lookupHit = hasProperty(value, names[index]);
+
+            value = value[names[index++]];
           }
+        } else {
+          value = context.view[name];
+          lookupHit = hasProperty(context.view, name);
         }
 
-        return renderedBefore + renderedContent + renderedAfter;
-      });
-    },
-
-    /*
-      Replace {{foo}} and friends with values from our view
-    */
-    render_tags: function (template, context, partials, in_recursion) {
-      // tit for tat
-      var that = this;
-
-      var new_regex = function () {
-        return that.getCachedRegex("render_tags", function (otag, ctag) {
-          return new RegExp(otag + "(=|!|>|&|\\{|%)?([^#\\^]+?)\\1?" + ctag + "+", "g");
-        });
-      };
-
-      var regex = new_regex();
-      var tag_replace_callback = function (match, operator, name) {
-        switch(operator) {
-        case "!": // ignore comments
-          return "";
-        case "=": // set new delimiters, rebuild the replace regexp
-          that.set_delimiters(name);
-          regex = new_regex();
-          return "";
-        case ">": // render partial
-          return that.render_partial(name, context, partials);
-        case "{": // the triple mustache is unescaped
-        case "&": // & operator is an alternative unescape method
-          return that.find(name, context);
-        default: // escape the value
-          return escapeHTML(that.find(name, context));
-        }
-      };
-      var lines = template.split("\n");
-      for(var i = 0; i < lines.length; i++) {
-        lines[i] = lines[i].replace(regex, tag_replace_callback, this);
-        if (!in_recursion) {
-          this.send(lines[i]);
-        }
-      }
+        if (lookupHit)
+          break;
 
-      if (in_recursion) {
-        return lines.join("\n");
-      }
-    },
-
-    set_delimiters: function (delimiters) {
-      var dels = delimiters.split(" ");
-      this.otag = this.escape_regex(dels[0]);
-      this.ctag = this.escape_regex(dels[1]);
-    },
-
-    escape_regex: function (text) {
-      // thank you Simon Willison
-      if (!arguments.callee.sRE) {
-        var specials = [
-          '/', '.', '*', '+', '?', '|',
-          '(', ')', '[', ']', '{', '}', '\\'
-        ];
-        arguments.callee.sRE = new RegExp(
-          '(\\' + specials.join('|\\') + ')', 'g'
-        );
-      }
-      return text.replace(arguments.callee.sRE, '\\$1');
-    },
-
-    /*
-      find `name` in current `context`. That is find me a value
-      from the view object
-    */
-    find: function (name, context) {
-      name = trim(name);
-
-      // Checks whether a value is thruthy or false or 0
-      function is_kinda_truthy(bool) {
-        return bool === false || bool === 0 || bool;
+        context = context.parent;
       }
 
-      var value;
+      cache[name] = value;
+    }
 
-      // check for dot notation eg. foo.bar
-      if (name.match(/([a-z_]+)\./ig)) {
-        var childValue = this.walk_context(name, context);
-        if (is_kinda_truthy(childValue)) {
-          value = childValue;
-        }
-      } else {
-        if (is_kinda_truthy(context[name])) {
-          value = context[name];
-        } else if (is_kinda_truthy(this.context[name])) {
-          value = this.context[name];
-        }
-      }
+    if (isFunction(value))
+      value = value.call(this.view);
 
-      if (typeof value == "function") {
-        return value.apply(context);
-      }
-      if (value !== undefined) {
-        return value;
-      }
-      // silently ignore unkown variables
-      return "";
-    },
-
-    walk_context: function (name, context) {
-      var path = name.split('.');
-      // if the var doesn't exist in current context, check the top level context
-      var value_context = (context[path[0]] != undefined) ? context : this.context;
-      var value = value_context[path.shift()];
-      while (value != undefined && path.length > 0) {
-        value_context = value;
-        value = value[path.shift()];
-      }
-      // if the value is a function, call it, binding the correct context
-      if (typeof value == "function") {
-        return value.apply(value_context);
+    return value;
+  };
+
+  /**
+   * A Writer knows how to take a stream of tokens and render them to a
+   * string, given a context. It also maintains a cache of templates to
+   * avoid the need to parse the same template twice.
+   */
+  function Writer () {
+    this.cache = {};
+  }
+
+  /**
+   * Clears all cached templates in this writer.
+   */
+  Writer.prototype.clearCache = function clearCache () {
+    this.cache = {};
+  };
+
+  /**
+   * Parses and caches the given `template` and returns the array of tokens
+   * that is generated from the parse.
+   */
+  Writer.prototype.parse = function parse (template, tags) {
+    var cache = this.cache;
+    var tokens = cache[template];
+
+    if (tokens == null)
+      tokens = cache[template] = parseTemplate(template, tags);
+
+    return tokens;
+  };
+
+  /**
+   * High-level method that is used to render the given `template` with
+   * the given `view`.
+   *
+   * The optional `partials` argument may be an object that contains the
+   * names and templates of partials that are used in the template. It may
+   * also be a function that is used to load partial templates on the fly
+   * that takes a single argument: the name of the partial.
+   */
+  Writer.prototype.render = function render (template, view, partials) {
+    var tokens = this.parse(template);
+    var context = (view instanceof Context) ? view : new Context(view);
+    return this.renderTokens(tokens, context, partials, template);
+  };
+
+  /**
+   * Low-level method that renders the given array of `tokens` using
+   * the given `context` and `partials`.
+   *
+   * Note: The `originalTemplate` is only ever used to extract the portion
+   * of the original template that was contained in a higher-order section.
+   * If the template doesn't use higher-order sections, this argument may
+   * be omitted.
+   */
+  Writer.prototype.renderTokens = function renderTokens (tokens, context, partials, originalTemplate) {
+    var buffer = '';
+
+    var token, symbol, value;
+    for (var i = 0, numTokens = tokens.length; i < numTokens; ++i) {
+      value = undefined;
+      token = tokens[i];
+      symbol = token[0];
+
+      if (symbol === '#') value = this.renderSection(token, context, partials, originalTemplate);
+      else if (symbol === '^') value = this.renderInverted(token, context, partials, originalTemplate);
+      else if (symbol === '>') value = this.renderPartial(token, context, partials, originalTemplate);
+      else if (symbol === '&') value = this.unescapedValue(token, context);
+      else if (symbol === 'name') value = this.escapedValue(token, context);
+      else if (symbol === 'text') value = this.rawValue(token);
+
+      if (value !== undefined)
+        buffer += value;
+    }
+
+    return buffer;
+  };
+
+  Writer.prototype.renderSection = function renderSection (token, context, partials, originalTemplate) {
+    var self = this;
+    var buffer = '';
+    var value = context.lookup(token[1]);
+
+    // This function is used to render an arbitrary template
+    // in the current context by higher-order sections.
+    function subRender (template) {
+      return self.render(template, context, partials);
+    }
+
+    if (!value) return;
+
+    if (isArray(value)) {
+      for (var j = 0, valueLength = value.length; j < valueLength; ++j) {
+        buffer += this.renderTokens(token[4], context.push(value[j]), partials, originalTemplate);
       }
+    } else if (typeof value === 'object' || typeof value === 'string' || typeof value === 'number') {
+      buffer += this.renderTokens(token[4], context.push(value), partials, originalTemplate);
+    } else if (isFunction(value)) {
+      if (typeof originalTemplate !== 'string')
+        throw new Error('Cannot use higher-order sections without the original template');
+
+      // Extract the portion of the original template that the section contains.
+      value = value.call(context.view, originalTemplate.slice(token[3], token[5]), subRender);
+
+      if (value != null)
+        buffer += value;
+    } else {
+      buffer += this.renderTokens(token[4], context, partials, originalTemplate);
+    }
+    return buffer;
+  };
+
+  Writer.prototype.renderInverted = function renderInverted (token, context, partials, originalTemplate) {
+    var value = context.lookup(token[1]);
+
+    // Use JavaScript's definition of falsy. Include empty arrays.
+    // See https://github.com/janl/mustache.js/issues/186
+    if (!value || (isArray(value) && value.length === 0))
+      return this.renderTokens(token[4], context, partials, originalTemplate);
+  };
+
+  Writer.prototype.renderPartial = function renderPartial (token, context, partials) {
+    if (!partials) return;
+
+    var value = isFunction(partials) ? partials(token[1]) : partials[token[1]];
+    if (value != null)
+      return this.renderTokens(this.parse(value), context, partials, value);
+  };
+
+  Writer.prototype.unescapedValue = function unescapedValue (token, context) {
+    var value = context.lookup(token[1]);
+    if (value != null)
       return value;
-    },
+  };
 
-    // Utility methods
+  Writer.prototype.escapedValue = function escapedValue (token, context) {
+    var value = context.lookup(token[1]);
+    if (value != null)
+      return mustache.escape(value);
+  };
 
-    /* includes tag */
-    includes: function (needle, haystack) {
-      return haystack.indexOf(this.otag + needle) != -1;
-    },
+  Writer.prototype.rawValue = function rawValue (token) {
+    return token[1];
+  };
 
-    // by @langalex, support for arrays of strings
-    create_context: function (_context) {
-      if (this.is_object(_context)) {
-        return _context;
-      } else {
-        var iterator = ".";
-        if (this.pragmas["IMPLICIT-ITERATOR"]) {
-          iterator = this.pragmas["IMPLICIT-ITERATOR"].iterator;
-        }
-        var ctx = {};
-        ctx[iterator] = _context;
-        return ctx;
-      }
-    },
-
-    is_object: function (a) {
-      return a && typeof a == "object";
-    },
-
-    /*
-      Why, why, why? Because IE. Cry, cry cry.
-    */
-    map: function (array, fn) {
-      if (typeof array.map == "function") {
-        return array.map(fn);
-      } else {
-        var r = [];
-        var l = array.length;
-        for(var i = 0; i < l; i++) {
-          r.push(fn(array[i]));
-        }
-        return r;
-      }
-    },
+  mustache.name = 'mustache.js';
+  mustache.version = '2.3.0';
+  mustache.tags = [ '{{', '}}' ];
 
-    getCachedRegex: function (name, generator) {
-      var byOtag = regexCache[this.otag];
-      if (!byOtag) {
-        byOtag = regexCache[this.otag] = {};
-      }
+  // All high-level mustache.* functions use this writer.
+  var defaultWriter = new Writer();
 
-      var byCtag = byOtag[this.ctag];
-      if (!byCtag) {
-        byCtag = byOtag[this.ctag] = {};
-      }
+  /**
+   * Clears all cached templates in the default writer.
+   */
+  mustache.clearCache = function clearCache () {
+    return defaultWriter.clearCache();
+  };
 
-      var regex = byCtag[name];
-      if (!regex) {
-        regex = byCtag[name] = generator(this.otag, this.ctag);
-      }
+  /**
+   * Parses and caches the given template in the default writer and returns the
+   * array of tokens it contains. Doing this ahead of time avoids the need to
+   * parse templates on the fly as they are rendered.
+   */
+  mustache.parse = function parse (template, tags) {
+    return defaultWriter.parse(template, tags);
+  };
 
-      return regex;
+  /**
+   * Renders the `template` with the given `view` and `partials` using the
+   * default writer.
+   */
+  mustache.render = function render (template, view, partials) {
+    if (typeof template !== 'string') {
+      throw new TypeError('Invalid template! Template should be a "string" ' +
+                          'but "' + typeStr(template) + '" was given as the first ' +
+                          'argument for mustache#render(template, view, partials)');
     }
+
+    return defaultWriter.render(template, view, partials);
   };
 
-  return({
-    name: "mustache.js",
-    version: "0.4.2",
-
-    /*
-      Turns a template and view into HTML
-    */
-    to_html: function (template, view, partials, send_fun) {
-      var renderer = new Renderer();
-      if (send_fun) {
-        renderer.send = send_fun;
-      }
-      renderer.render(template, view || {}, partials);
-      if (!send_fun) {
-        return renderer.buffer.join("\n");
-      }
+  // This is here for backwards compatibility with 0.4.x.,
+  /*eslint-disable */ // eslint wants camel cased function name
+  mustache.to_html = function to_html (template, view, partials, send) {
+    /*eslint-enable*/
+
+    var result = mustache.render(template, view, partials);
+
+    if (isFunction(send)) {
+      send(result);
+    } else {
+      return result;
     }
-  });
-}();
+  };
+
+  // Export the escaping function so that the user may override it.
+  // See https://github.com/janl/mustache.js/issues/244
+  mustache.escape = escapeHtml;
+
+  // Export these mainly for testing, but also for advanced usage.
+  mustache.Scanner = Scanner;
+  mustache.Context = Context;
+  mustache.Writer = Writer;
+
+  return mustache;
+}));
diff --git a/mustache.js.nuspec b/mustache.js.nuspec
index 5ca1bb5..bad8f81 100644
--- a/mustache.js.nuspec
+++ b/mustache.js.nuspec
@@ -2,7 +2,7 @@
 <package >
   <metadata>
     <id>mustache.js</id>
-    <version>0.4.2</version>
+    <version>2.3.0</version>
     <authors>mustache.js Authors</authors>
     <licenseUrl>https://github.com/janl/mustache.js/blob/master/LICENSE</licenseUrl>
     <projectUrl>http://mustache.github.com/</projectUrl>
diff --git a/mustache.min.js b/mustache.min.js
index 8014bcf..520cfcb 100644
--- a/mustache.min.js
+++ b/mustache.min.js
@@ -1,6 +1 @@
-/*! Version: 0.4.2 */
-/*
-  mustache.js — Logic-less templates in JavaScript
-
-  See http://mustache.github.com/ for more info.
-*/var Mustache=function(){function g(a){return String(a).replace(/&(?!#?\w+;)|[<>"']/g,function(a){return f[a]||a})}var a=Object.prototype.toString;Array.isArray=Array.isArray||function(b){return a.call(b)=="[object Array]"};var b=String.prototype.trim,c;if(b)c=function(a){return a==null?"":b.call(a)};else{var d,e;/\S/.test(" ")?(d=/^[\s\xA0]+/,e=/[\s\xA0]+$/):(d=/^\s+/,e=/\s+$/),c=function(a){return a==null?"":a.toString().replace(d,"").replace(e,"")}}var f={"&":"&","<":"<",">":" [...]
\ No newline at end of file
+(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){ret [...]
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..d307805
--- /dev/null
+++ b/package.json
@@ -0,0 +1,61 @@
+{
+  "name": "mustache",
+  "version": "2.3.0",
+  "description": "Logic-less {{mustache}} templates with JavaScript",
+  "author": "mustache.js Authors <http://github.com/janl/mustache.js>",
+  "homepage": "https://github.com/janl/mustache.js",
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/janl/mustache.js.git"
+  },
+  "keywords": [
+    "mustache",
+    "template",
+    "templates",
+    "ejs"
+  ],
+  "main": "./mustache.js",
+  "bin": {
+    "mustache": "./bin/mustache"
+  },
+  "files": [
+    "mustache.js",
+    "mustache.min.js",
+    "bin",
+    "wrappers",
+    "LICENSE"
+  ],
+  "volo": {
+    "url": "https://raw.github.com/janl/mustache.js/{version}/mustache.js"
+  },
+  "engines": {
+    "npm": ">=1.4.0"
+  },
+  "scripts": {
+    "pretest": "eslint mustache.js bin/mustache",
+    "test": "mocha --reporter spec test/*-test.js",
+    "test-render": "mocha  --reporter spec test/render-test",
+    "pre-test-browser": "node test/create-browser-suite.js",
+    "test-browser": "npm run pre-test-browser && zuul -- test/context-test.js test/parse-test.js test/scanner-test.js test/render-test-browser.js",
+    "test-browser-local": "npm run pre-test-browser && zuul --local 8080 -- test/context-test.js test/scanner-test.js test/parse-test.js test/render-test-browser.js"
+  },
+  "devDependencies": {
+    "chai": "^3.4.0",
+    "eslint": "^2.5.1",
+    "mocha": "^3.0.2",
+    "zuul": "^3.11.0"
+  },
+  "spm": {
+    "main": "mustache.js",
+    "ignore": [
+      "test",
+      "wrappers"
+    ]
+  },
+  "greenkeeper": {
+    "ignore": [
+      "eslint"
+    ]
+  },
+  "license": "MIT"
+}
diff --git a/spec/_files/ampersand_escape.js b/spec/_files/ampersand_escape.js
deleted file mode 100644
index 645efe1..0000000
--- a/spec/_files/ampersand_escape.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var ampersand_escape = {
-  message: "Some <code>"
-};
diff --git a/spec/_files/apostrophe.js b/spec/_files/apostrophe.js
deleted file mode 100644
index df69cd2..0000000
--- a/spec/_files/apostrophe.js
+++ /dev/null
@@ -1 +0,0 @@
-var apostrophe = {'apos': "'", 'control':'X'};
diff --git a/spec/_files/array_of_partials_partial.js b/spec/_files/array_of_partials_partial.js
deleted file mode 100644
index 45611cf..0000000
--- a/spec/_files/array_of_partials_partial.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var partial_context = { 
-  numbers: [{i: '1'}, {i: '2'}, {i: '3'}, {i: '4'}]
-};
diff --git a/spec/_files/array_of_strings.js b/spec/_files/array_of_strings.js
deleted file mode 100644
index 12c4992..0000000
--- a/spec/_files/array_of_strings.js
+++ /dev/null
@@ -1 +0,0 @@
-var array_of_strings = {array_of_strings: ['hello', 'world']};
diff --git a/spec/_files/array_of_strings.mustache b/spec/_files/array_of_strings.mustache
deleted file mode 100644
index 2898705..0000000
--- a/spec/_files/array_of_strings.mustache
+++ /dev/null
@@ -1 +0,0 @@
-{{#array_of_strings}}{{.}} {{/array_of_strings}}
\ No newline at end of file
diff --git a/spec/_files/array_of_strings_options.js b/spec/_files/array_of_strings_options.js
deleted file mode 100644
index 2e29adf..0000000
--- a/spec/_files/array_of_strings_options.js
+++ /dev/null
@@ -1 +0,0 @@
-var array_of_strings_options = {array_of_strings_options: ['hello', 'world']};
diff --git a/spec/_files/array_of_strings_options.mustache b/spec/_files/array_of_strings_options.mustache
deleted file mode 100644
index 6b28278..0000000
--- a/spec/_files/array_of_strings_options.mustache
+++ /dev/null
@@ -1,2 +0,0 @@
-{{%IMPLICIT-ITERATOR iterator=rob}}
-{{#array_of_strings_options}}{{rob}} {{/array_of_strings_options}}
\ No newline at end of file
diff --git a/spec/_files/array_of_strings_options.txt b/spec/_files/array_of_strings_options.txt
deleted file mode 100644
index 4a1f475..0000000
--- a/spec/_files/array_of_strings_options.txt
+++ /dev/null
@@ -1 +0,0 @@
-hello world 
diff --git a/spec/_files/array_partial.js b/spec/_files/array_partial.js
deleted file mode 100644
index 88d7592..0000000
--- a/spec/_files/array_partial.js
+++ /dev/null
@@ -1,5 +0,0 @@
-var partial_context = { 
-  partial: {
-    array: ['1', '2', '3', '4']
-  }
-};
\ No newline at end of file
diff --git a/spec/_files/bom_as_whitespace.js b/spec/_files/bom_as_whitespace.js
new file mode 100644
index 0000000..4bce3e1
--- /dev/null
+++ b/spec/_files/bom_as_whitespace.js
@@ -0,0 +1 @@
+var bom_as_whitespace = {'tag': 'Tag name w/o BOM', '\uFEFFtag': 'Tag name with BOM'};
\ No newline at end of file
diff --git a/spec/_files/bom_as_whitespace.mustache b/spec/_files/bom_as_whitespace.mustache
new file mode 100644
index 0000000..5189a19
--- /dev/null
+++ b/spec/_files/bom_as_whitespace.mustache
@@ -0,0 +1 @@
+{{tag}}
\ No newline at end of file
diff --git a/spec/_files/bom_as_whitespace.txt b/spec/_files/bom_as_whitespace.txt
new file mode 100644
index 0000000..76ef3f1
--- /dev/null
+++ b/spec/_files/bom_as_whitespace.txt
@@ -0,0 +1 @@
+Tag name w/o BOM
\ No newline at end of file
diff --git a/spec/_files/bug_11_eating_whitespace.js b/spec/_files/bug_11_eating_whitespace.js
deleted file mode 100644
index 78ce975..0000000
--- a/spec/_files/bug_11_eating_whitespace.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var bug_11_eating_whitespace = {
-  tag: "yo"
-};
diff --git a/spec/_files/comments.js b/spec/_files/comments.js
deleted file mode 100644
index f85f979..0000000
--- a/spec/_files/comments.js
+++ /dev/null
@@ -1,5 +0,0 @@
-var comments = {
-  title: function() {
-    return "A Comedy of Errors";
-  }
-};
diff --git a/spec/_files/complex.txt b/spec/_files/complex.txt
deleted file mode 100644
index b51ca10..0000000
--- a/spec/_files/complex.txt
+++ /dev/null
@@ -1,6 +0,0 @@
-<h1>Colors</h1>
-  <ul>
-      <li><strong>red</strong></li>
-      <li><a href="#Green">green</a></li>
-      <li><a href="#Blue">blue</a></li>
-  </ul>
diff --git a/spec/_files/empty_partial.2.mustache b/spec/_files/empty_partial.2.mustache
deleted file mode 100644
index b920295..0000000
--- a/spec/_files/empty_partial.2.mustache
+++ /dev/null
@@ -1 +0,0 @@
-yo
\ No newline at end of file
diff --git a/spec/_files/empty_partial.js b/spec/_files/empty_partial.js
deleted file mode 100644
index 9cc53c6..0000000
--- a/spec/_files/empty_partial.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var partial_context = {
-  foo: 1
-};
diff --git a/spec/_files/empty_sections.js b/spec/_files/empty_sections.js
deleted file mode 100644
index 6e50514..0000000
--- a/spec/_files/empty_sections.js
+++ /dev/null
@@ -1 +0,0 @@
-var empty_sections = {};
diff --git a/spec/_files/empty_template.js b/spec/_files/empty_template.js
deleted file mode 100644
index 564c9e2..0000000
--- a/spec/_files/empty_template.js
+++ /dev/null
@@ -1 +0,0 @@
-var empty_template = {};
diff --git a/spec/_files/empty_template.txt b/spec/_files/empty_template.txt
deleted file mode 100644
index 60652b6..0000000
--- a/spec/_files/empty_template.txt
+++ /dev/null
@@ -1 +0,0 @@
-<html><head></head><body><h1>Test</h1></body></html>
diff --git a/spec/_files/error_not_found.js b/spec/_files/error_not_found.js
deleted file mode 100644
index 6cdbdb3..0000000
--- a/spec/_files/error_not_found.js
+++ /dev/null
@@ -1 +0,0 @@
-var error_not_found = {bar: 2};
\ No newline at end of file
diff --git a/spec/_files/escaped.js b/spec/_files/escaped.js
deleted file mode 100644
index 875776a..0000000
--- a/spec/_files/escaped.js
+++ /dev/null
@@ -1,7 +0,0 @@
-var escaped = {
-  title: function() {
-    return "Bear > Shark";
-  },
-  subtitle: 'Rock 'n Roll',
-  entities: """
-};
diff --git a/spec/_files/escaped.mustache b/spec/_files/escaped.mustache
deleted file mode 100644
index b8f82d0..0000000
--- a/spec/_files/escaped.mustache
+++ /dev/null
@@ -1,3 +0,0 @@
-<h1>{{title}}</h1>
-<h2>{{subtitle}}</h2>
-But not {{entities}}.
diff --git a/spec/_files/escaped.txt b/spec/_files/escaped.txt
deleted file mode 100644
index 7f750d4..0000000
--- a/spec/_files/escaped.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-<h1>Bear > Shark</h1>
-<h2>Rock 'n Roll</h2>
-But not ".
diff --git a/spec/_files/higher_order_sections.js b/spec/_files/higher_order_sections.js
deleted file mode 100644
index c7e558e..0000000
--- a/spec/_files/higher_order_sections.js
+++ /dev/null
@@ -1,9 +0,0 @@
-var higher_order_sections = {
-  "name": "Tater",
-  "helper": "To tinker?",
-  "bolder": function() {
-    return function(text, render) {
-      return "<b>" + render(text) + '</b> ' + this.helper;
-    }
-  }
-}
\ No newline at end of file
diff --git a/spec/_files/higher_order_sections.txt b/spec/_files/higher_order_sections.txt
deleted file mode 100644
index 9db786a..0000000
--- a/spec/_files/higher_order_sections.txt
+++ /dev/null
@@ -1 +0,0 @@
-<b>Hi Tater.</b> To tinker?
diff --git a/spec/_files/inverted_section.js b/spec/_files/inverted_section.js
deleted file mode 100644
index cb96ecf..0000000
--- a/spec/_files/inverted_section.js
+++ /dev/null
@@ -1,3 +0,0 @@
-var inverted_section =  {
-  "repo": []
-}
diff --git a/spec/_files/inverted_section.mustache b/spec/_files/inverted_section.mustache
deleted file mode 100644
index beec558..0000000
--- a/spec/_files/inverted_section.mustache
+++ /dev/null
@@ -1,2 +0,0 @@
-{{#repo}}<b>{{name}}</b>{{/repo}}
-{{^repo}}No repos :({{/repo}}
diff --git a/spec/_files/nesting.txt b/spec/_files/nesting.txt
deleted file mode 100644
index caf5afd..0000000
--- a/spec/_files/nesting.txt
+++ /dev/null
@@ -1,4 +0,0 @@
-      1
-        2
-        3
-  
diff --git a/spec/_files/partial_recursion.2.mustache b/spec/_files/partial_recursion.2.mustache
deleted file mode 100644
index 457d2a0..0000000
--- a/spec/_files/partial_recursion.2.mustache
+++ /dev/null
@@ -1,4 +0,0 @@
-{{name}}
-{{#children}}
-{{>partial}}
-{{/children}}
\ No newline at end of file
diff --git a/spec/_files/partial_recursion.js b/spec/_files/partial_recursion.js
deleted file mode 100644
index ad1f2eb..0000000
--- a/spec/_files/partial_recursion.js
+++ /dev/null
@@ -1,11 +0,0 @@
-var partial_context = {
-  name: '1',
-  kids: [
-    {
-      name: '1.1',
-      children: [
-        {name: '1.1.1'}
-      ]
-    }
-  ]
-};
diff --git a/spec/_files/partial_recursion.mustache b/spec/_files/partial_recursion.mustache
deleted file mode 100644
index d965a6a..0000000
--- a/spec/_files/partial_recursion.mustache
+++ /dev/null
@@ -1,4 +0,0 @@
-{{name}}
-{{#kids}}
-{{>partial}}
-{{/kids}}
\ No newline at end of file
diff --git a/spec/_files/partial_recursion.txt b/spec/_files/partial_recursion.txt
deleted file mode 100644
index 0f70515..0000000
--- a/spec/_files/partial_recursion.txt
+++ /dev/null
@@ -1,3 +0,0 @@
-1
-1.1
-1.1.1
diff --git a/spec/_files/reuse_of_enumerables.js b/spec/_files/reuse_of_enumerables.js
deleted file mode 100644
index 543e121..0000000
--- a/spec/_files/reuse_of_enumerables.js
+++ /dev/null
@@ -1,6 +0,0 @@
-var reuse_of_enumerables = {
-  terms: [
-    {name: 't1', index: 0},
-    {name: 't2', index: 1},
-  ]
-};
\ No newline at end of file
diff --git a/spec/_files/template_partial.2.mustache b/spec/_files/template_partial.2.mustache
deleted file mode 100644
index 54bdd7d..0000000
--- a/spec/_files/template_partial.2.mustache
+++ /dev/null
@@ -1 +0,0 @@
-Again, {{again}}!
\ No newline at end of file
diff --git a/spec/_files/template_partial.js b/spec/_files/template_partial.js
deleted file mode 100644
index 68a4317..0000000
--- a/spec/_files/template_partial.js
+++ /dev/null
@@ -1,8 +0,0 @@
-var partial_context = {
-  title: function() {
-    return "Welcome";
-  },
-  partial: {
-    again: "Goodbye"
-  }
-}
diff --git a/spec/_files/two_in_a_row.mustache b/spec/_files/two_in_a_row.mustache
deleted file mode 100644
index dc38602..0000000
--- a/spec/_files/two_in_a_row.mustache
+++ /dev/null
@@ -1 +0,0 @@
-{{greeting}}, {{name}}!
\ No newline at end of file
diff --git a/spec/_files/two_sections.js b/spec/_files/two_sections.js
deleted file mode 100644
index 8546f64..0000000
--- a/spec/_files/two_sections.js
+++ /dev/null
@@ -1 +0,0 @@
-var two_sections = {};
\ No newline at end of file
diff --git a/spec/_files/two_sections.txt b/spec/_files/two_sections.txt
deleted file mode 100644
index 8b13789..0000000
--- a/spec/_files/two_sections.txt
+++ /dev/null
@@ -1 +0,0 @@
-
diff --git a/spec/_files/unescaped.js b/spec/_files/unescaped.js
deleted file mode 100644
index 0bd20b8..0000000
--- a/spec/_files/unescaped.js
+++ /dev/null
@@ -1,5 +0,0 @@
-var unescaped = {
-  title: function() {
-    return "Bear > Shark";
-  }
-};
diff --git a/spec/_files/unescaped.mustache b/spec/_files/unescaped.mustache
deleted file mode 100644
index 9982708..0000000
--- a/spec/_files/unescaped.mustache
+++ /dev/null
@@ -1 +0,0 @@
-<h1>{{{title}}}</h1>
\ No newline at end of file
diff --git a/spec/_files/unknown_pragma.js b/spec/_files/unknown_pragma.js
deleted file mode 100644
index 68344a5..0000000
--- a/spec/_files/unknown_pragma.js
+++ /dev/null
@@ -1 +0,0 @@
-var unknown_pragma = {};
diff --git a/spec/_files/unknown_pragma.mustache b/spec/_files/unknown_pragma.mustache
deleted file mode 100644
index 113810d..0000000
--- a/spec/_files/unknown_pragma.mustache
+++ /dev/null
@@ -1 +0,0 @@
-{{%I-HAVE-THE-GREATEST-MUSTACHE}}
diff --git a/spec/_files/unknown_pragma.txt b/spec/_files/unknown_pragma.txt
deleted file mode 100644
index a34840d..0000000
--- a/spec/_files/unknown_pragma.txt
+++ /dev/null
@@ -1 +0,0 @@
-ERROR: This implementation of mustache doesn't understand the 'I-HAVE-THE-GREATEST-MUSTACHE' pragma
diff --git a/spec/_files/view_partial.js b/spec/_files/view_partial.js
deleted file mode 100644
index 30ade55..0000000
--- a/spec/_files/view_partial.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var partial_context = {
-  greeting: function() {
-    return "Welcome";
-  },
-
-  farewell: function() {
-    return "Fair enough, right?";
-  },
-
-  partial: {
-    name: "Chris",
-    value: 10000,
-    taxed_value: function() {
-      return this.value - (this.value * 0.4);
-    },
-    in_ca: true
-  }
-};
-
diff --git a/spec/_files/whitespace_partial.js b/spec/_files/whitespace_partial.js
deleted file mode 100644
index 30ade55..0000000
--- a/spec/_files/whitespace_partial.js
+++ /dev/null
@@ -1,19 +0,0 @@
-var partial_context = {
-  greeting: function() {
-    return "Welcome";
-  },
-
-  farewell: function() {
-    return "Fair enough, right?";
-  },
-
-  partial: {
-    name: "Chris",
-    value: 10000,
-    taxed_value: function() {
-      return this.value - (this.value * 0.4);
-    },
-    in_ca: true
-  }
-};
-
diff --git a/spec/mustache_spec.rb b/spec/mustache_spec.rb
deleted file mode 100644
index e04bec1..0000000
--- a/spec/mustache_spec.rb
+++ /dev/null
@@ -1,276 +0,0 @@
-require 'rubygems'
-require 'json'
-
-ROOT = File.expand_path('../..', __FILE__)
-SPEC = File.join(ROOT, 'spec')
-FILES = File.join(SPEC, '_files')
-
-MUSTACHE = File.read(File.join(ROOT, "mustache.js"))
-
-TESTS = Dir.glob(File.join(FILES, '*.js')).map do |name|
-  File.basename name, '.js'
-end
-
-PARTIALS = TESTS.select {|t| t.include? "partial" }
-NON_PARTIALS = TESTS.select {|t| not t.include? "partial" }
-
-NODE_PATH = `which node`.strip
-JS_PATH = `which js`.strip
-JSC_PATH = "/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc"
-RHINO_JAR = "org.mozilla.javascript.tools.shell.Main"
-
-def load_test(name, is_partial=false)
-  view = File.read(File.join(FILES, "#{name}.js"))
-  template = File.read(File.join(FILES, "#{name}.mustache")).to_json
-  expect = File.read(File.join(FILES, "#{name}.txt"))
-
-  test = [view, template, expect]
-
-  if is_partial
-    test << File.read(File.join(FILES, "#{name}.2.mustache")).to_json
-  end
-
-  test
-end
-
-def run_js(runner, js)
-  cmd = case runner
-    when :spidermonkey
-      JS_PATH
-    when :jsc
-      JSC_PATH
-    when :rhino
-      "java #{RHINO_JAR}"
-    when :node
-      NODE_PATH
-    end
-
-  runner_file = "runner.js"
-  File.open(runner_file, 'w') {|file| file.write(js) }
-  `#{cmd} #{runner_file}`
-ensure
-  FileUtils.rm_r(runner_file)
-end
-
-$engines_run = 0
-
-describe "mustache" do
-  shared_examples_for "mustache rendering" do
-    before(:all) do
-      $engines_run += 1
-    end
-
-    it "should return the same when invoked multiple times" do
-      js = <<-JS
-        #{@boilerplate}
-        Mustache.to_html("x")
-        print(Mustache.to_html("x"));
-      JS
-
-      run_js(@runner, js).should == "x\n"
-    end
-
-    it "should clear the context after each run" do
-      js = <<-JS
-        #{@boilerplate}
-        Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{x: 1}]})
-        try {
-          print(Mustache.to_html("{{#list}}{{x}}{{/list}}", {list: [{}]}));
-        } catch(e) {
-          print('ERROR: ' + e.message);
-        }
-      JS
-
-      run_js(@runner, js).should == "\n"
-    end
-
-    NON_PARTIALS.each do |test|
-      describe test do
-        it "should generate the correct html" do
-          view, template, expect = load_test(test)
-
-          js = <<-JS
-            try {
-              #{@boilerplate}
-              #{view}
-              var template = #{template};
-              var result = Mustache.to_html(template, #{test});
-              print(result);
-            } catch(e) {
-              print('ERROR: ' + e.message);
-            }
-          JS
-
-          run_js(@runner, js).should == expect
-        end
-
-        it "should sendFun the correct html" do
-          view, template, expect = load_test(test)
-
-          js = <<-JS
-            try {
-              #{@boilerplate}
-              #{view}
-              var chunks = [];
-              var sendFun = function(chunk) {
-                if (chunk != "") {
-                  chunks.push(chunk);
-                }
-              }
-              var template = #{template};
-              Mustache.to_html(template, #{test}, null, sendFun);
-              print(chunks.join("\\n"));
-            } catch(e) {
-              print('ERROR: ' + e.message);
-            }
-          JS
-
-          run_js(@runner, js).strip.should == expect.strip
-        end
-      end
-    end
-
-    PARTIALS.each do |test|
-      describe test do
-        it "should generate the correct html" do
-          view, template, expect, partial = load_test(test, true)
-
-          js = <<-JS
-            try {
-              #{@boilerplate}
-              #{view}
-              var template = #{template};
-              var partials = {"partial": #{partial}};
-              var result = Mustache.to_html(template, partial_context, partials);
-              print(result);
-            } catch(e) {
-              print('ERROR: ' + e.message);
-            }
-          JS
-
-          run_js(@runner, js).should == expect
-        end
-
-        it "should sendFun the correct html" do
-          view, template, expect, partial = load_test(test, true)
-
-          js = <<-JS
-            try {
-              #{@boilerplate}
-              #{view};
-              var template = #{template};
-              var partials = {"partial": #{partial}};
-              var chunks = [];
-              var sendFun = function(chunk) {
-                if (chunk != "") {
-                  chunks.push(chunk);
-                }
-              }
-              Mustache.to_html(template, partial_context, partials, sendFun);
-              print(chunks.join("\\n"));
-            } catch(e) {
-              print('ERROR: ' + e.message);
-            }
-          JS
-
-          run_js(@runner, js).strip.should == expect.strip
-        end
-      end
-    end
-  end
-
-  context "running in node" do
-    if File.exist?(NODE_PATH)
-      before(:all) do
-        $stdout.write "Testing in node "
-        @runner = :node
-        @boilerplate = MUSTACHE.dup
-        @boilerplate << <<-JS
-        function print(message) {
-          console.log(message);
-        }
-        JS
-      end
-
-      after(:all) do
-        puts " Done!"
-      end
-
-      it_should_behave_like "mustache rendering"
-    else
-      puts "Skipping tests in node (node not found)"
-    end
-  end
-
-  context "running in SpiderMonkey (Mozilla, Firefox)" do
-    if File.exist?(JS_PATH)
-      before(:all) do
-        $stdout.write "Testing in SpiderMonkey "
-        @runner = :spidermonkey
-        @boilerplate = MUSTACHE.dup
-      end
-
-      after(:all) do
-        puts " Done!"
-      end
-
-      it_should_behave_like "mustache rendering"
-    else
-      puts "Skipping tests in SpiderMonkey (js not found)"
-    end
-  end
-
-  context "running in JavaScriptCore (WebKit, Safari)" do
-    if File.exist?(JSC_PATH)
-      before(:all) do
-        $stdout.write "Testing in JavaScriptCore "
-        @runner = :jsc
-        @boilerplate = MUSTACHE.dup
-      end
-
-      after(:all) do
-        puts " Done!"
-      end
-
-      it_should_behave_like "mustache rendering"
-    else
-      puts "Skipping tests in JavaScriptCore (jsc not found)"
-    end
-  end
-
-  context "running in Rhino (Mozilla, Java)" do
-    if `java #{RHINO_JAR} 'foo' 2>&1` !~ /ClassNotFoundException/
-      before(:all) do
-        $stdout.write "Testing in Rhino "
-        @runner = :rhino
-        @boilerplate = MUSTACHE.dup
-      end
-
-      after(:all) do
-        puts " Done!"
-      end
-
-      it_should_behave_like "mustache rendering"
-    else
-      puts "Skipping tests in Rhino (JAR #{RHINO_JAR} was not found)"
-    end
-  end
-
-  context "suite" do
-    before(:each) do
-      $stdout.write "Verifying that we ran at the tests in at least one engine ... "
-    end
-
-    after(:each) do
-      if @exception.nil?
-        puts "OK"
-      else
-        puts "ERROR!"
-      end
-    end
-
-    it "should have run at least one time" do
-      $engines_run.should > 0
-    end
-  end
-end
diff --git a/test/_files/ampersand_escape.js b/test/_files/ampersand_escape.js
new file mode 100644
index 0000000..df6409f
--- /dev/null
+++ b/test/_files/ampersand_escape.js
@@ -0,0 +1,3 @@
+({
+  message: "Some <code>"
+})
diff --git a/spec/_files/ampersand_escape.mustache b/test/_files/ampersand_escape.mustache
similarity index 100%
rename from spec/_files/ampersand_escape.mustache
rename to test/_files/ampersand_escape.mustache
diff --git a/spec/_files/ampersand_escape.txt b/test/_files/ampersand_escape.txt
similarity index 100%
rename from spec/_files/ampersand_escape.txt
rename to test/_files/ampersand_escape.txt
diff --git a/test/_files/apostrophe.js b/test/_files/apostrophe.js
new file mode 100644
index 0000000..183c6d5
--- /dev/null
+++ b/test/_files/apostrophe.js
@@ -0,0 +1,4 @@
+({
+  'apos': "'",
+  'control': 'X'
+})
diff --git a/spec/_files/apostrophe.mustache b/test/_files/apostrophe.mustache
similarity index 100%
rename from spec/_files/apostrophe.mustache
rename to test/_files/apostrophe.mustache
diff --git a/spec/_files/apostrophe.txt b/test/_files/apostrophe.txt
similarity index 100%
rename from spec/_files/apostrophe.txt
rename to test/_files/apostrophe.txt
diff --git a/test/_files/array_of_strings.js b/test/_files/array_of_strings.js
new file mode 100644
index 0000000..6926612
--- /dev/null
+++ b/test/_files/array_of_strings.js
@@ -0,0 +1,3 @@
+({
+  array_of_strings: ['hello', 'world']
+})
diff --git a/test/_files/array_of_strings.mustache b/test/_files/array_of_strings.mustache
new file mode 100644
index 0000000..4d65738
--- /dev/null
+++ b/test/_files/array_of_strings.mustache
@@ -0,0 +1 @@
+{{#array_of_strings}}{{.}} {{/array_of_strings}}
diff --git a/spec/_files/array_of_strings.txt b/test/_files/array_of_strings.txt
similarity index 100%
rename from spec/_files/array_of_strings.txt
rename to test/_files/array_of_strings.txt
diff --git a/test/_files/avoids_obj_prototype_in_view_cache.js b/test/_files/avoids_obj_prototype_in_view_cache.js
new file mode 100644
index 0000000..2ab58cd
--- /dev/null
+++ b/test/_files/avoids_obj_prototype_in_view_cache.js
@@ -0,0 +1,4 @@
+({
+  valueOf: 'Avoids methods',
+  watch: 'in Object.prototype'
+})
diff --git a/test/_files/avoids_obj_prototype_in_view_cache.mustache b/test/_files/avoids_obj_prototype_in_view_cache.mustache
new file mode 100644
index 0000000..f6e469b
--- /dev/null
+++ b/test/_files/avoids_obj_prototype_in_view_cache.mustache
@@ -0,0 +1 @@
+{{valueOf}} {{watch}}
\ No newline at end of file
diff --git a/test/_files/avoids_obj_prototype_in_view_cache.txt b/test/_files/avoids_obj_prototype_in_view_cache.txt
new file mode 100644
index 0000000..2621d99
--- /dev/null
+++ b/test/_files/avoids_obj_prototype_in_view_cache.txt
@@ -0,0 +1 @@
+Avoids methods in Object.prototype
\ No newline at end of file
diff --git a/test/_files/backslashes.js b/test/_files/backslashes.js
new file mode 100644
index 0000000..427acd9
--- /dev/null
+++ b/test/_files/backslashes.js
@@ -0,0 +1,3 @@
+({
+  value: "\\abc"
+})
diff --git a/test/_files/backslashes.mustache b/test/_files/backslashes.mustache
new file mode 100644
index 0000000..fe7745b
--- /dev/null
+++ b/test/_files/backslashes.mustache
@@ -0,0 +1,7 @@
+* {{value}}
+* {{{value}}}
+* {{&value}}
+<script>
+foo = { bar: 'abc\"xyz\"' };
+foo = { bar: 'x\'y' };
+</script>
diff --git a/test/_files/backslashes.txt b/test/_files/backslashes.txt
new file mode 100644
index 0000000..038dd37
--- /dev/null
+++ b/test/_files/backslashes.txt
@@ -0,0 +1,7 @@
+* \abc
+* \abc
+* \abc
+<script>
+foo = { bar: 'abc\"xyz\"' };
+foo = { bar: 'x\'y' };
+</script>
diff --git a/test/_files/bug_11_eating_whitespace.js b/test/_files/bug_11_eating_whitespace.js
new file mode 100644
index 0000000..e41ccd1
--- /dev/null
+++ b/test/_files/bug_11_eating_whitespace.js
@@ -0,0 +1,3 @@
+({
+  tag: "yo"
+})
diff --git a/spec/_files/bug_11_eating_whitespace.mustache b/test/_files/bug_11_eating_whitespace.mustache
similarity index 100%
rename from spec/_files/bug_11_eating_whitespace.mustache
rename to test/_files/bug_11_eating_whitespace.mustache
diff --git a/spec/_files/bug_11_eating_whitespace.txt b/test/_files/bug_11_eating_whitespace.txt
similarity index 100%
rename from spec/_files/bug_11_eating_whitespace.txt
rename to test/_files/bug_11_eating_whitespace.txt
diff --git a/test/_files/bug_length_property.js b/test/_files/bug_length_property.js
new file mode 100644
index 0000000..74c483b
--- /dev/null
+++ b/test/_files/bug_length_property.js
@@ -0,0 +1,3 @@
+({
+    length: 'hello'
+})
diff --git a/test/_files/bug_length_property.mustache b/test/_files/bug_length_property.mustache
new file mode 100644
index 0000000..b000887
--- /dev/null
+++ b/test/_files/bug_length_property.mustache
@@ -0,0 +1 @@
+{{#length}}The length variable is: {{length}}{{/length}}
diff --git a/test/_files/bug_length_property.txt b/test/_files/bug_length_property.txt
new file mode 100644
index 0000000..f5355d3
--- /dev/null
+++ b/test/_files/bug_length_property.txt
@@ -0,0 +1 @@
+The length variable is: hello
diff --git a/test/_files/changing_delimiters.js b/test/_files/changing_delimiters.js
new file mode 100644
index 0000000..b808f4c
--- /dev/null
+++ b/test/_files/changing_delimiters.js
@@ -0,0 +1,4 @@
+({
+  "foo": "foooooooooooooo",
+  "bar": "<b>bar!</b>"
+})
diff --git a/test/_files/changing_delimiters.mustache b/test/_files/changing_delimiters.mustache
new file mode 100644
index 0000000..0cd044c
--- /dev/null
+++ b/test/_files/changing_delimiters.mustache
@@ -0,0 +1 @@
+{{=<% %>=}}<% foo %> {{foo}} <%{bar}%> {{{bar}}}
diff --git a/test/_files/changing_delimiters.txt b/test/_files/changing_delimiters.txt
new file mode 100644
index 0000000..1b1510d
--- /dev/null
+++ b/test/_files/changing_delimiters.txt
@@ -0,0 +1 @@
+foooooooooooooo {{foo}} <b>bar!</b> {{{bar}}}
diff --git a/test/_files/check_falsy.js b/test/_files/check_falsy.js
new file mode 100644
index 0000000..5a599ca
--- /dev/null
+++ b/test/_files/check_falsy.js
@@ -0,0 +1,7 @@
+({
+  number: function(text, render) {
+    return function(text, render) {
+      return +render(text);
+    }
+  }
+})
diff --git a/test/_files/check_falsy.mustache b/test/_files/check_falsy.mustache
new file mode 100644
index 0000000..30e2547
--- /dev/null
+++ b/test/_files/check_falsy.mustache
@@ -0,0 +1 @@
+<p>{{#number}}0{{/number}}</p>
diff --git a/test/_files/check_falsy.txt b/test/_files/check_falsy.txt
new file mode 100644
index 0000000..3bb2f51
--- /dev/null
+++ b/test/_files/check_falsy.txt
@@ -0,0 +1 @@
+<p>0</p>
diff --git a/test/_files/cli.json b/test/_files/cli.json
new file mode 100644
index 0000000..50e75aa
--- /dev/null
+++ b/test/_files/cli.json
@@ -0,0 +1,3 @@
+{
+  "name": "LeBron"
+}
diff --git a/test/_files/cli.mustache b/test/_files/cli.mustache
new file mode 100644
index 0000000..c14fd89
--- /dev/null
+++ b/test/_files/cli.mustache
@@ -0,0 +1 @@
+Howdy {{name}}, CLI rox
\ No newline at end of file
diff --git a/test/_files/cli.txt b/test/_files/cli.txt
new file mode 100644
index 0000000..66556fe
--- /dev/null
+++ b/test/_files/cli.txt
@@ -0,0 +1 @@
+Howdy LeBron, CLI rox
\ No newline at end of file
diff --git a/test/_files/cli_with_partials.json b/test/_files/cli_with_partials.json
new file mode 100644
index 0000000..c6af1c8
--- /dev/null
+++ b/test/_files/cli_with_partials.json
@@ -0,0 +1,14 @@
+{ "users": [
+    {
+      "name": "LeBron"
+    },
+    {
+      "name": "LeBron 2"
+    }
+  ],
+  "comments": [
+    {
+      "title": "A Comedy of Errors"
+    }
+  ]
+}
\ No newline at end of file
diff --git a/test/_files/cli_with_partials.mustache b/test/_files/cli_with_partials.mustache
new file mode 100644
index 0000000..9c168d8
--- /dev/null
+++ b/test/_files/cli_with_partials.mustache
@@ -0,0 +1,7 @@
+{{#users}}
+{{>cli}}
+{{/users}}
+
+{{#comments}}
+{{>comments}}
+{{/comments}}
\ No newline at end of file
diff --git a/test/_files/cli_with_partials.txt b/test/_files/cli_with_partials.txt
new file mode 100644
index 0000000..f582397
--- /dev/null
+++ b/test/_files/cli_with_partials.txt
@@ -0,0 +1,2 @@
+Howdy LeBron, CLI roxHowdy LeBron 2, CLI rox
+<h1>A Comedy of Errors</h1>
diff --git a/test/_files/comments.js b/test/_files/comments.js
new file mode 100644
index 0000000..f20b8b1
--- /dev/null
+++ b/test/_files/comments.js
@@ -0,0 +1,5 @@
+({
+  title: function () {
+    return "A Comedy of Errors";
+  }
+})
diff --git a/spec/_files/comments.mustache b/test/_files/comments.mustache
similarity index 100%
rename from spec/_files/comments.mustache
rename to test/_files/comments.mustache
diff --git a/spec/_files/comments.txt b/test/_files/comments.txt
similarity index 100%
rename from spec/_files/comments.txt
rename to test/_files/comments.txt
diff --git a/spec/_files/complex.js b/test/_files/complex.js
similarity index 74%
rename from spec/_files/complex.js
rename to test/_files/complex.js
index a0dfb63..68a4809 100644
--- a/spec/_files/complex.js
+++ b/test/_files/complex.js
@@ -1,5 +1,5 @@
-var complex = {
-  header: function() {
+({
+  header: function () {
     return "Colors";
   },
   item: [
@@ -7,13 +7,13 @@ var complex = {
       {name: "green", current: false, url: "#Green"},
       {name: "blue", current: false, url: "#Blue"}
   ],
-  link: function() {
+  link: function () {
     return this["current"] !== true;
   },
-  list: function() {
+  list: function () {
     return this.item.length !== 0;
   },
-  empty: function() {
+  empty: function () {
     return this.item.length === 0;
   }
-};
+})
diff --git a/spec/_files/complex.mustache b/test/_files/complex.mustache
similarity index 95%
rename from spec/_files/complex.mustache
rename to test/_files/complex.mustache
index 23bec3c..869a4f0 100644
--- a/spec/_files/complex.mustache
+++ b/test/_files/complex.mustache
@@ -13,4 +13,4 @@
 {{/list}}
 {{#empty}}
   <p>The list is empty.</p>
-{{/empty}}
\ No newline at end of file
+{{/empty}}
diff --git a/test/_files/complex.txt b/test/_files/complex.txt
new file mode 100644
index 0000000..596d3f6
--- /dev/null
+++ b/test/_files/complex.txt
@@ -0,0 +1,6 @@
+<h1>Colors</h1>
+  <ul>
+  <li><strong>red</strong></li>
+  <li><a href="#Green">green</a></li>
+  <li><a href="#Blue">blue</a></li>
+  </ul>
diff --git a/test/_files/context_lookup.js b/test/_files/context_lookup.js
new file mode 100644
index 0000000..8ce6299
--- /dev/null
+++ b/test/_files/context_lookup.js
@@ -0,0 +1,8 @@
+({
+  "outer": {
+    "id": 1,
+    "second": {
+      "nothing": 2
+    }
+  }
+})
diff --git a/test/_files/context_lookup.mustache b/test/_files/context_lookup.mustache
new file mode 100644
index 0000000..3c7b767
--- /dev/null
+++ b/test/_files/context_lookup.mustache
@@ -0,0 +1 @@
+{{#outer}}{{#second}}{{id}}{{/second}}{{/outer}}
diff --git a/test/_files/context_lookup.txt b/test/_files/context_lookup.txt
new file mode 100644
index 0000000..d00491f
--- /dev/null
+++ b/test/_files/context_lookup.txt
@@ -0,0 +1 @@
+1
diff --git a/spec/_files/delimiters.js b/test/_files/delimiters.js
similarity index 89%
rename from spec/_files/delimiters.js
rename to test/_files/delimiters.js
index 220d0d2..365d01e 100644
--- a/spec/_files/delimiters.js
+++ b/test/_files/delimiters.js
@@ -1,6 +1,6 @@
-var delimiters = {
+({
   first: "It worked the first time.",
   second: "And it worked the second time.",
   third: "Then, surprisingly, it worked the third time.",
   fourth: "Fourth time also fine!."
-}
+})
diff --git a/spec/_files/delimiters.mustache b/test/_files/delimiters.mustache
similarity index 82%
rename from spec/_files/delimiters.mustache
rename to test/_files/delimiters.mustache
index a73e061..7fac846 100644
--- a/spec/_files/delimiters.mustache
+++ b/test/_files/delimiters.mustache
@@ -4,4 +4,4 @@
 <%=| |=%>
 * | third |
 |={{ }}=|
-* {{ fourth }}
\ No newline at end of file
+* {{ fourth }}
diff --git a/spec/_files/delimiters.txt b/test/_files/delimiters.txt
similarity index 100%
rename from spec/_files/delimiters.txt
rename to test/_files/delimiters.txt
diff --git a/test/_files/disappearing_whitespace.js b/test/_files/disappearing_whitespace.js
new file mode 100644
index 0000000..973dd1c
--- /dev/null
+++ b/test/_files/disappearing_whitespace.js
@@ -0,0 +1,4 @@
+({
+  bedrooms: true,
+  total: 1
+})
diff --git a/test/_files/disappearing_whitespace.mustache b/test/_files/disappearing_whitespace.mustache
new file mode 100644
index 0000000..16c16e0
--- /dev/null
+++ b/test/_files/disappearing_whitespace.mustache
@@ -0,0 +1 @@
+{{#bedrooms}}{{total}}{{/bedrooms}} BED
diff --git a/test/_files/disappearing_whitespace.txt b/test/_files/disappearing_whitespace.txt
new file mode 100644
index 0000000..66e98ef
--- /dev/null
+++ b/test/_files/disappearing_whitespace.txt
@@ -0,0 +1 @@
+1 BED
diff --git a/spec/_files/dot_notation.js b/test/_files/dot_notation.js
similarity index 70%
rename from spec/_files/dot_notation.js
rename to test/_files/dot_notation.js
index c1295f5..de06a03 100644
--- a/spec/_files/dot_notation.js
+++ b/test/_files/dot_notation.js
@@ -1,17 +1,17 @@
-var dot_notation = {
+({
   name: "A Book",
   authors: ["John Power", "Jamie Walsh"],
-  price:{
+  price: {
     value: 200,
-    vat: function() {
+    vat: function () {
       return this.value * 0.2;
     },
     currency: {
-      symbol: '€',
-      name: 'Euro'
+      symbol: '$',
+      name: 'USD'
     }
   },
-  availability:{
+  availability: {
     status: true,
     text: "In Stock"
   },
@@ -20,4 +20,4 @@ var dot_notation = {
     zero: 0,
     notTrue: false
   }
-};
+})
diff --git a/spec/_files/dot_notation.mustache b/test/_files/dot_notation.mustache
similarity index 53%
rename from spec/_files/dot_notation.mustache
rename to test/_files/dot_notation.mustache
index da1bad7..f89d70b 100644
--- a/spec/_files/dot_notation.mustache
+++ b/test/_files/dot_notation.mustache
@@ -1,8 +1,8 @@
 <!-- exciting part -->
 <h1>{{name}}</h1>
 <p>Authors: <ul>{{#authors}}<li>{{.}}</li>{{/authors}}</ul></p>
-<p>Price: {{price.currency.symbol}}{{price.value}} {{#price.currency}}{{name}} <b>{{availability.text}}</b>{{/price.currency}}</p>
-<p>VAT: {{price.currency.symbol}}{{price.vat}}</p>
+<p>Price: {{{price.currency.symbol}}}{{price.value}} {{#price.currency}}{{name}} <b>{{availability.text}}</b>{{/price.currency}}</p>
+<p>VAT: {{{price.currency.symbol}}}{{#price}}{{vat}}{{/price}}</p>
 <!-- boring part -->
 <h2>Test truthy false values:</h2>
 <p>Zero: {{truthy.zero}}</p>
diff --git a/spec/_files/dot_notation.txt b/test/_files/dot_notation.txt
similarity index 74%
rename from spec/_files/dot_notation.txt
rename to test/_files/dot_notation.txt
index d0e4707..08afa05 100644
--- a/spec/_files/dot_notation.txt
+++ b/test/_files/dot_notation.txt
@@ -1,8 +1,8 @@
 <!-- exciting part -->
 <h1>A Book</h1>
 <p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p>
-<p>Price: €200 Euro <b>In Stock</b></p>
-<p>VAT: €40</p>
+<p>Price: $200 USD <b>In Stock</b></p>
+<p>VAT: $40</p>
 <!-- boring part -->
 <h2>Test truthy false values:</h2>
 <p>Zero: 0</p>
diff --git a/spec/_files/double_render.js b/test/_files/double_render.js
similarity index 65%
rename from spec/_files/double_render.js
rename to test/_files/double_render.js
index 24125dc..28acb2c 100644
--- a/spec/_files/double_render.js
+++ b/test/_files/double_render.js
@@ -1,5 +1,5 @@
-var double_render = {
+({
   foo: true,
   bar: "{{win}}",
   win: "FAIL"
-};
\ No newline at end of file
+})
diff --git a/spec/_files/double_render.mustache b/test/_files/double_render.mustache
similarity index 100%
rename from spec/_files/double_render.mustache
rename to test/_files/double_render.mustache
diff --git a/spec/_files/double_render.txt b/test/_files/double_render.txt
similarity index 100%
rename from spec/_files/double_render.txt
rename to test/_files/double_render.txt
diff --git a/test/_files/empty_list.js b/test/_files/empty_list.js
new file mode 100644
index 0000000..c0e1159
--- /dev/null
+++ b/test/_files/empty_list.js
@@ -0,0 +1,3 @@
+({
+  jobs: []
+})
diff --git a/test/_files/empty_list.mustache b/test/_files/empty_list.mustache
new file mode 100644
index 0000000..4fdf13d
--- /dev/null
+++ b/test/_files/empty_list.mustache
@@ -0,0 +1,4 @@
+These are the jobs:
+{{#jobs}}
+{{.}}
+{{/jobs}}
diff --git a/test/_files/empty_list.txt b/test/_files/empty_list.txt
new file mode 100644
index 0000000..d9b4a67
--- /dev/null
+++ b/test/_files/empty_list.txt
@@ -0,0 +1 @@
+These are the jobs:
diff --git a/test/_files/empty_sections.js b/test/_files/empty_sections.js
new file mode 100644
index 0000000..b4100a5
--- /dev/null
+++ b/test/_files/empty_sections.js
@@ -0,0 +1 @@
+({})
diff --git a/spec/_files/empty_sections.mustache b/test/_files/empty_sections.mustache
similarity index 100%
rename from spec/_files/empty_sections.mustache
rename to test/_files/empty_sections.mustache
diff --git a/spec/_files/empty_sections.txt b/test/_files/empty_sections.txt
similarity index 100%
rename from spec/_files/empty_sections.txt
rename to test/_files/empty_sections.txt
diff --git a/test/_files/empty_string.js b/test/_files/empty_string.js
new file mode 100644
index 0000000..be6e058
--- /dev/null
+++ b/test/_files/empty_string.js
@@ -0,0 +1,6 @@
+({
+  description: "That is all!",
+  child: {
+    description: ""
+  }
+})
diff --git a/test/_files/empty_string.mustache b/test/_files/empty_string.mustache
new file mode 100644
index 0000000..f568441
--- /dev/null
+++ b/test/_files/empty_string.mustache
@@ -0,0 +1 @@
+{{description}}{{#child}}{{description}}{{/child}}
diff --git a/test/_files/empty_string.txt b/test/_files/empty_string.txt
new file mode 100644
index 0000000..22e2a6e
--- /dev/null
+++ b/test/_files/empty_string.txt
@@ -0,0 +1 @@
+That is all!
diff --git a/test/_files/empty_template.js b/test/_files/empty_template.js
new file mode 100644
index 0000000..b4100a5
--- /dev/null
+++ b/test/_files/empty_template.js
@@ -0,0 +1 @@
+({})
diff --git a/spec/_files/empty_template.mustache b/test/_files/empty_template.mustache
similarity index 100%
copy from spec/_files/empty_template.mustache
copy to test/_files/empty_template.mustache
diff --git a/spec/_files/empty_template.mustache b/test/_files/empty_template.txt
similarity index 100%
rename from spec/_files/empty_template.mustache
rename to test/_files/empty_template.txt
diff --git a/test/_files/error_not_found.js b/test/_files/error_not_found.js
new file mode 100644
index 0000000..10e4709
--- /dev/null
+++ b/test/_files/error_not_found.js
@@ -0,0 +1,3 @@
+({
+  bar: 2
+})
diff --git a/spec/_files/error_not_found.mustache b/test/_files/error_not_found.mustache
similarity index 100%
rename from spec/_files/error_not_found.mustache
rename to test/_files/error_not_found.mustache
diff --git a/test/_files/error_not_found.txt b/test/_files/error_not_found.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/_files/escaped.js b/test/_files/escaped.js
new file mode 100644
index 0000000..4276a39
--- /dev/null
+++ b/test/_files/escaped.js
@@ -0,0 +1,7 @@
+({
+  title: function () {
+    return "Bear > Shark";
+  },
+  symbol: null,
+  entities: "" \"'<>`=/"
+})
diff --git a/test/_files/escaped.mustache b/test/_files/escaped.mustache
new file mode 100644
index 0000000..5c44268
--- /dev/null
+++ b/test/_files/escaped.mustache
@@ -0,0 +1,2 @@
+<h1>{{title}}{{symbol}}</h1>
+And even {{entities}}, but not {{{entities}}}.
diff --git a/test/_files/escaped.txt b/test/_files/escaped.txt
new file mode 100644
index 0000000..182f99e
--- /dev/null
+++ b/test/_files/escaped.txt
@@ -0,0 +1,2 @@
+<h1>Bear > Shark</h1>
+And even &quot; "'<>&#x60;&#x3D;&#x2F;, but not " "'<>`=/.
diff --git a/test/_files/falsy.js b/test/_files/falsy.js
new file mode 100644
index 0000000..ae9b9bf
--- /dev/null
+++ b/test/_files/falsy.js
@@ -0,0 +1,8 @@
+({
+  "emptyString": "",
+  "emptyArray": [],
+  "zero": 0,
+  "null": null,
+  "undefined": undefined,
+  "NaN": 0/0
+})
\ No newline at end of file
diff --git a/test/_files/falsy.mustache b/test/_files/falsy.mustache
new file mode 100644
index 0000000..f3698da
--- /dev/null
+++ b/test/_files/falsy.mustache
@@ -0,0 +1,12 @@
+{{#emptyString}}empty string{{/emptyString}}
+{{^emptyString}}inverted empty string{{/emptyString}}
+{{#emptyArray}}empty array{{/emptyArray}}
+{{^emptyArray}}inverted empty array{{/emptyArray}}
+{{#zero}}zero{{/zero}}
+{{^zero}}inverted zero{{/zero}}
+{{#null}}null{{/null}}
+{{^null}}inverted null{{/null}}
+{{#undefined}}undefined{{/undefined}}
+{{^undefined}}inverted undefined{{/undefined}}
+{{#NaN}}NaN{{/NaN}}
+{{^NaN}}inverted NaN{{/NaN}}
diff --git a/test/_files/falsy.txt b/test/_files/falsy.txt
new file mode 100644
index 0000000..9b7cde3
--- /dev/null
+++ b/test/_files/falsy.txt
@@ -0,0 +1,12 @@
+
+inverted empty string
+
+inverted empty array
+
+inverted zero
+
+inverted null
+
+inverted undefined
+
+inverted NaN
diff --git a/test/_files/falsy_array.js b/test/_files/falsy_array.js
new file mode 100644
index 0000000..f265308
--- /dev/null
+++ b/test/_files/falsy_array.js
@@ -0,0 +1,10 @@
+({
+  "list": [
+  	["", "emptyString"],
+  	[[], "emptyArray"],
+  	[0, "zero"],
+  	[null, "null"],
+  	[undefined, "undefined"],
+  	[0/0, "NaN"]
+  ]
+})
\ No newline at end of file
diff --git a/test/_files/falsy_array.mustache b/test/_files/falsy_array.mustache
new file mode 100644
index 0000000..2be7b37
--- /dev/null
+++ b/test/_files/falsy_array.mustache
@@ -0,0 +1,3 @@
+{{#list}}
+{{#.}}{{#.}}{{.}}{{/.}}{{^.}}inverted {{/.}}{{/.}}
+{{/list}}
\ No newline at end of file
diff --git a/test/_files/falsy_array.txt b/test/_files/falsy_array.txt
new file mode 100644
index 0000000..6f24529
--- /dev/null
+++ b/test/_files/falsy_array.txt
@@ -0,0 +1,6 @@
+inverted emptyString
+inverted emptyArray
+inverted zero
+inverted null
+inverted undefined
+inverted NaN
diff --git a/test/_files/grandparent_context.js b/test/_files/grandparent_context.js
new file mode 100644
index 0000000..97dbfd3
--- /dev/null
+++ b/test/_files/grandparent_context.js
@@ -0,0 +1,19 @@
+({
+  grand_parent_id: 'grand_parent1',
+  parent_contexts: [
+    {
+      parent_id: 'parent1',
+      child_contexts: [
+        { child_id: 'parent1-child1' },
+        { child_id: 'parent1-child2' }
+      ]
+    },
+    {
+      parent_id: 'parent2',
+      child_contexts: [
+        { child_id: 'parent2-child1' },
+        { child_id: 'parent2-child2' }
+      ]
+    }
+  ]
+})
diff --git a/test/_files/grandparent_context.mustache b/test/_files/grandparent_context.mustache
new file mode 100644
index 0000000..e6c07a2
--- /dev/null
+++ b/test/_files/grandparent_context.mustache
@@ -0,0 +1,10 @@
+{{grand_parent_id}}
+{{#parent_contexts}}
+{{grand_parent_id}}
+{{parent_id}}
+{{#child_contexts}}
+{{grand_parent_id}}
+{{parent_id}}
+{{child_id}}
+{{/child_contexts}}
+{{/parent_contexts}}
diff --git a/test/_files/grandparent_context.txt b/test/_files/grandparent_context.txt
new file mode 100644
index 0000000..64996ad
--- /dev/null
+++ b/test/_files/grandparent_context.txt
@@ -0,0 +1,17 @@
+grand_parent1
+grand_parent1
+parent1
+grand_parent1
+parent1
+parent1-child1
+grand_parent1
+parent1
+parent1-child2
+grand_parent1
+parent2
+grand_parent1
+parent2
+parent2-child1
+grand_parent1
+parent2
+parent2-child2
diff --git a/test/_files/higher_order_sections.js b/test/_files/higher_order_sections.js
new file mode 100644
index 0000000..bacb0a4
--- /dev/null
+++ b/test/_files/higher_order_sections.js
@@ -0,0 +1,9 @@
+({
+  name: "Tater",
+  helper: "To tinker?",
+  bolder: function () {
+    return function (text, render) {
+      return text + ' => <b>' + render(text) + '</b> ' + this.helper;
+    }
+  }
+})
diff --git a/spec/_files/higher_order_sections.mustache b/test/_files/higher_order_sections.mustache
similarity index 100%
rename from spec/_files/higher_order_sections.mustache
rename to test/_files/higher_order_sections.mustache
diff --git a/test/_files/higher_order_sections.txt b/test/_files/higher_order_sections.txt
new file mode 100644
index 0000000..be50ad7
--- /dev/null
+++ b/test/_files/higher_order_sections.txt
@@ -0,0 +1 @@
+Hi {{name}}. => <b>Hi Tater.</b> To tinker?
diff --git a/test/_files/implicit_iterator.js b/test/_files/implicit_iterator.js
new file mode 100644
index 0000000..2be2997
--- /dev/null
+++ b/test/_files/implicit_iterator.js
@@ -0,0 +1,8 @@
+({
+  data: {
+    author: {
+      twitter_id: 819606,
+      name: 'janl'
+    }
+  }
+})
diff --git a/test/_files/implicit_iterator.mustache b/test/_files/implicit_iterator.mustache
new file mode 100644
index 0000000..ae31f34
--- /dev/null
+++ b/test/_files/implicit_iterator.mustache
@@ -0,0 +1,7 @@
+{{# data.author.twitter_id }}
+<meta name="twitter:site:id" content="{{.}}">
+{{/ data.author.twitter_id }}
+
+{{# data.author.name }}
+<meta name="twitter:site" content="{{.}}">
+{{/ data.author.name }}
diff --git a/test/_files/implicit_iterator.txt b/test/_files/implicit_iterator.txt
new file mode 100644
index 0000000..0fccefd
--- /dev/null
+++ b/test/_files/implicit_iterator.txt
@@ -0,0 +1,3 @@
+<meta name="twitter:site:id" content="819606">
+
+<meta name="twitter:site" content="janl">
diff --git a/test/_files/included_tag.js b/test/_files/included_tag.js
new file mode 100644
index 0000000..eb032a4
--- /dev/null
+++ b/test/_files/included_tag.js
@@ -0,0 +1,3 @@
+({
+  html: "I like {{mustache}}"
+})
diff --git a/test/_files/included_tag.mustache b/test/_files/included_tag.mustache
new file mode 100644
index 0000000..70631c2
--- /dev/null
+++ b/test/_files/included_tag.mustache
@@ -0,0 +1 @@
+You said "{{{html}}}" today
diff --git a/test/_files/included_tag.txt b/test/_files/included_tag.txt
new file mode 100644
index 0000000..1af4556
--- /dev/null
+++ b/test/_files/included_tag.txt
@@ -0,0 +1 @@
+You said "I like {{mustache}}" today
diff --git a/test/_files/inverted_section.js b/test/_files/inverted_section.js
new file mode 100644
index 0000000..f8f08fd
--- /dev/null
+++ b/test/_files/inverted_section.js
@@ -0,0 +1,3 @@
+({
+  "repos": []
+})
diff --git a/test/_files/inverted_section.mustache b/test/_files/inverted_section.mustache
new file mode 100644
index 0000000..b0a183b
--- /dev/null
+++ b/test/_files/inverted_section.mustache
@@ -0,0 +1,3 @@
+{{#repos}}<b>{{name}}</b>{{/repos}}
+{{^repos}}No repos :({{/repos}}
+{{^nothin}}Hello!{{/nothin}}
diff --git a/spec/_files/inverted_section.txt b/test/_files/inverted_section.txt
similarity index 60%
rename from spec/_files/inverted_section.txt
rename to test/_files/inverted_section.txt
index 5fd0de1..b421582 100644
--- a/spec/_files/inverted_section.txt
+++ b/test/_files/inverted_section.txt
@@ -1 +1,3 @@
+
 No repos :(
+Hello!
diff --git a/spec/_files/keys_with_questionmarks.js b/test/_files/keys_with_questionmarks.js
similarity index 50%
rename from spec/_files/keys_with_questionmarks.js
rename to test/_files/keys_with_questionmarks.js
index 55a220d..becd631 100644
--- a/spec/_files/keys_with_questionmarks.js
+++ b/test/_files/keys_with_questionmarks.js
@@ -1,5 +1,5 @@
-var keys_with_questionmarks = {
+({
   "person?": {
     name: "Jon"
   }
-}
+})
diff --git a/spec/_files/keys_with_questionmarks.mustache b/test/_files/keys_with_questionmarks.mustache
similarity index 100%
rename from spec/_files/keys_with_questionmarks.mustache
rename to test/_files/keys_with_questionmarks.mustache
diff --git a/spec/_files/keys_with_questionmarks.txt b/test/_files/keys_with_questionmarks.txt
similarity index 100%
rename from spec/_files/keys_with_questionmarks.txt
rename to test/_files/keys_with_questionmarks.txt
diff --git a/test/_files/malicious_template.js b/test/_files/malicious_template.js
new file mode 100644
index 0000000..b4100a5
--- /dev/null
+++ b/test/_files/malicious_template.js
@@ -0,0 +1 @@
+({})
diff --git a/test/_files/malicious_template.mustache b/test/_files/malicious_template.mustache
new file mode 100644
index 0000000..b956867
--- /dev/null
+++ b/test/_files/malicious_template.mustache
@@ -0,0 +1,5 @@
+{{"+(function () {throw "evil"})()+"}}
+{{{"+(function () {throw "evil"})()+"}}}
+{{> "+(function () {throw "evil"})()+"}}
+{{# "+(function () {throw "evil"})()+"}}
+{{/ "+(function () {throw "evil"})()+"}}
diff --git a/spec/_files/error_not_found.txt b/test/_files/malicious_template.txt
similarity index 50%
rename from spec/_files/error_not_found.txt
rename to test/_files/malicious_template.txt
index 8b13789..139597f 100644
--- a/spec/_files/error_not_found.txt
+++ b/test/_files/malicious_template.txt
@@ -1 +1,2 @@
 
+
diff --git a/test/_files/multiline_comment.js b/test/_files/multiline_comment.js
new file mode 100644
index 0000000..b4100a5
--- /dev/null
+++ b/test/_files/multiline_comment.js
@@ -0,0 +1 @@
+({})
diff --git a/test/_files/multiline_comment.mustache b/test/_files/multiline_comment.mustache
new file mode 100644
index 0000000..dff0893
--- /dev/null
+++ b/test/_files/multiline_comment.mustache
@@ -0,0 +1,6 @@
+{{!
+
+This is a multi-line comment.
+
+}}
+Hello world!
diff --git a/test/_files/multiline_comment.txt b/test/_files/multiline_comment.txt
new file mode 100644
index 0000000..cd08755
--- /dev/null
+++ b/test/_files/multiline_comment.txt
@@ -0,0 +1 @@
+Hello world!
diff --git a/test/_files/nested_dot.js b/test/_files/nested_dot.js
new file mode 100644
index 0000000..2c22f8e
--- /dev/null
+++ b/test/_files/nested_dot.js
@@ -0,0 +1 @@
+({ name: 'Bruno' })
diff --git a/test/_files/nested_dot.mustache b/test/_files/nested_dot.mustache
new file mode 100644
index 0000000..12b0728
--- /dev/null
+++ b/test/_files/nested_dot.mustache
@@ -0,0 +1 @@
+{{#name}}Hello {{.}}{{/name}}
\ No newline at end of file
diff --git a/test/_files/nested_dot.txt b/test/_files/nested_dot.txt
new file mode 100644
index 0000000..58df047
--- /dev/null
+++ b/test/_files/nested_dot.txt
@@ -0,0 +1 @@
+Hello Bruno
\ No newline at end of file
diff --git a/test/_files/nested_higher_order_sections.js b/test/_files/nested_higher_order_sections.js
new file mode 100644
index 0000000..3ccf4d3
--- /dev/null
+++ b/test/_files/nested_higher_order_sections.js
@@ -0,0 +1,8 @@
+({
+  bold: function () {
+    return function (text, render) {
+      return '<b>' + render(text) + '</b>';
+    };
+  },
+  person: { name: 'Jonas' }
+});
diff --git a/test/_files/nested_higher_order_sections.mustache b/test/_files/nested_higher_order_sections.mustache
new file mode 100644
index 0000000..e312fe7
--- /dev/null
+++ b/test/_files/nested_higher_order_sections.mustache
@@ -0,0 +1 @@
+{{#bold}}{{#person}}My name is {{name}}!{{/person}}{{/bold}}
diff --git a/test/_files/nested_higher_order_sections.txt b/test/_files/nested_higher_order_sections.txt
new file mode 100644
index 0000000..0ee6a40
--- /dev/null
+++ b/test/_files/nested_higher_order_sections.txt
@@ -0,0 +1 @@
+<b>My name is Jonas!</b>
diff --git a/test/_files/nested_iterating.js b/test/_files/nested_iterating.js
new file mode 100644
index 0000000..2708b2d
--- /dev/null
+++ b/test/_files/nested_iterating.js
@@ -0,0 +1,8 @@
+({
+  inner: [{
+    foo: 'foo',
+    inner: [{
+      bar: 'bar'
+    }]
+  }]
+})
diff --git a/test/_files/nested_iterating.mustache b/test/_files/nested_iterating.mustache
new file mode 100644
index 0000000..1a3bb1a
--- /dev/null
+++ b/test/_files/nested_iterating.mustache
@@ -0,0 +1 @@
+{{#inner}}{{foo}}{{#inner}}{{bar}}{{/inner}}{{/inner}}
diff --git a/test/_files/nested_iterating.txt b/test/_files/nested_iterating.txt
new file mode 100644
index 0000000..323fae0
--- /dev/null
+++ b/test/_files/nested_iterating.txt
@@ -0,0 +1 @@
+foobar
diff --git a/spec/_files/nesting.js b/test/_files/nesting.js
similarity index 76%
rename from spec/_files/nesting.js
rename to test/_files/nesting.js
index 1f76cd0..264cc2f 100644
--- a/spec/_files/nesting.js
+++ b/test/_files/nesting.js
@@ -1,7 +1,7 @@
-var nesting = {
+({
   foo: [
     {a: {b: 1}},
     {a: {b: 2}},
     {a: {b: 3}}
   ]
-};
+})
diff --git a/spec/_files/nesting.mustache b/test/_files/nesting.mustache
similarity index 100%
rename from spec/_files/nesting.mustache
rename to test/_files/nesting.mustache
diff --git a/test/_files/nesting.txt b/test/_files/nesting.txt
new file mode 100644
index 0000000..7db34b1
--- /dev/null
+++ b/test/_files/nesting.txt
@@ -0,0 +1,3 @@
+    1
+    2
+    3
diff --git a/test/_files/nesting_same_name.js b/test/_files/nesting_same_name.js
new file mode 100644
index 0000000..10a0c14
--- /dev/null
+++ b/test/_files/nesting_same_name.js
@@ -0,0 +1,8 @@
+({
+  items: [
+    {
+      name: 'name',
+      items: [1, 2, 3, 4]
+    }
+  ]
+})
diff --git a/test/_files/nesting_same_name.mustache b/test/_files/nesting_same_name.mustache
new file mode 100644
index 0000000..777dbd6
--- /dev/null
+++ b/test/_files/nesting_same_name.mustache
@@ -0,0 +1 @@
+{{#items}}{{name}}{{#items}}{{.}}{{/items}}{{/items}}
diff --git a/test/_files/nesting_same_name.txt b/test/_files/nesting_same_name.txt
new file mode 100644
index 0000000..34fcfd3
--- /dev/null
+++ b/test/_files/nesting_same_name.txt
@@ -0,0 +1 @@
+name1234
diff --git a/test/_files/null_lookup_array.js b/test/_files/null_lookup_array.js
new file mode 100644
index 0000000..9ebf56a
--- /dev/null
+++ b/test/_files/null_lookup_array.js
@@ -0,0 +1,9 @@
+({
+    "name": "David",
+    "twitter": "@dasilvacontin",
+    "farray": [
+    	["Flor", "@florrts"],
+    	["Miquel", null],
+    	["Chris", undefined]
+    ]
+})
diff --git a/test/_files/null_lookup_array.mustache b/test/_files/null_lookup_array.mustache
new file mode 100644
index 0000000..0543895
--- /dev/null
+++ b/test/_files/null_lookup_array.mustache
@@ -0,0 +1,3 @@
+{{#farray}}
+{{#.}}{{#.}}{{.}} {{/.}}{{^.}}no twitter{{/.}}{{/.}}
+{{/farray}}
diff --git a/test/_files/null_lookup_array.txt b/test/_files/null_lookup_array.txt
new file mode 100644
index 0000000..94edf99
--- /dev/null
+++ b/test/_files/null_lookup_array.txt
@@ -0,0 +1,3 @@
+Flor @florrts 
+Miquel no twitter
+Chris no twitter
diff --git a/test/_files/null_lookup_object.js b/test/_files/null_lookup_object.js
new file mode 100644
index 0000000..2f2efd7
--- /dev/null
+++ b/test/_files/null_lookup_object.js
@@ -0,0 +1,31 @@
+({
+  "name": "David",
+  "twitter": "@dasilvacontin",
+  "fobject": [
+    {
+      "name": "Flor",
+      "twitter": "@florrts"
+    },
+    {
+      "name": "Miquel",
+      "twitter": null
+    },
+    {
+	"name": "Chris",
+	"twitter": undefined
+    }
+  ],
+  "favorites": {
+    "color": "blue",
+    "president": "Bush",
+    "show": "Futurama"
+  },
+  "mascot": {
+    "name": "Squid",
+    "favorites": {
+      "color": "orange",
+      "president": undefined,
+      "show": null
+    }
+  }
+})
diff --git a/test/_files/null_lookup_object.mustache b/test/_files/null_lookup_object.mustache
new file mode 100644
index 0000000..243e218
--- /dev/null
+++ b/test/_files/null_lookup_object.mustache
@@ -0,0 +1,9 @@
+{{#fobject}}
+{{name}}'s twitter: {{#twitter}}{{.}}{{/twitter}}{{^twitter}}unknown{{/twitter}}.
+{{/fobject}}
+
+{{#mascot}}
+{{name}}'s favorite color: {{#favorites.color}}{{.}}{{/favorites.color}}{{^favorites.color}}no one{{/favorites.color}}.
+{{name}}'s favorite president: {{#favorites.president}}{{.}}{{/favorites.president}}{{^favorites.president}}no one{{/favorites.president}}.
+{{name}}'s favorite show: {{#favorites.show}}{{.}}{{/favorites.show}}{{^favorites.show}}none{{/favorites.show}}.
+{{/mascot}}
diff --git a/test/_files/null_lookup_object.txt b/test/_files/null_lookup_object.txt
new file mode 100644
index 0000000..0f71bdb
--- /dev/null
+++ b/test/_files/null_lookup_object.txt
@@ -0,0 +1,7 @@
+Flor's twitter: @florrts.
+Miquel's twitter: unknown.
+Chris's twitter: unknown.
+
+Squid's favorite color: orange.
+Squid's favorite president: no one.
+Squid's favorite show: none.
diff --git a/spec/_files/null_string.js b/test/_files/null_string.js
similarity index 80%
rename from spec/_files/null_string.js
rename to test/_files/null_string.js
index 93414a1..984ee51 100644
--- a/spec/_files/null_string.js
+++ b/test/_files/null_string.js
@@ -1,9 +1,10 @@
-var null_string = {
+({
   name: "Elise",
   glytch: true,
   binary: false,
   value: null,
+  undef: undefined,
   numeric: function() {
     return NaN;
   }
-};
+})
diff --git a/spec/_files/null_string.mustache b/test/_files/null_string.mustache
similarity index 65%
rename from spec/_files/null_string.mustache
rename to test/_files/null_string.mustache
index 12bcb08..a6f3300 100644
--- a/spec/_files/null_string.mustache
+++ b/test/_files/null_string.mustache
@@ -2,4 +2,5 @@ Hello {{name}}
 glytch {{glytch}}
 binary {{binary}}
 value {{value}}
-numeric {{numeric}}
\ No newline at end of file
+undef {{undef}}
+numeric {{numeric}}
diff --git a/spec/_files/null_string.txt b/test/_files/null_string.txt
similarity index 88%
rename from spec/_files/null_string.txt
rename to test/_files/null_string.txt
index 827569b..bcabe0a 100644
--- a/spec/_files/null_string.txt
+++ b/test/_files/null_string.txt
@@ -2,4 +2,5 @@ Hello Elise
 glytch true
 binary false
 value 
+undef 
 numeric NaN
diff --git a/test/_files/null_view.js b/test/_files/null_view.js
new file mode 100644
index 0000000..dbdae72
--- /dev/null
+++ b/test/_files/null_view.js
@@ -0,0 +1,4 @@
+({
+  name: 'Joe',
+  friends: null
+})
diff --git a/test/_files/null_view.mustache b/test/_files/null_view.mustache
new file mode 100644
index 0000000..115b376
--- /dev/null
+++ b/test/_files/null_view.mustache
@@ -0,0 +1 @@
+{{name}}'s friends: {{#friends}}{{name}}, {{/friends}}
\ No newline at end of file
diff --git a/test/_files/null_view.txt b/test/_files/null_view.txt
new file mode 100644
index 0000000..15ed2ab
--- /dev/null
+++ b/test/_files/null_view.txt
@@ -0,0 +1 @@
+Joe's friends: 
\ No newline at end of file
diff --git a/test/_files/partial_array.js b/test/_files/partial_array.js
new file mode 100644
index 0000000..2a6ddf1
--- /dev/null
+++ b/test/_files/partial_array.js
@@ -0,0 +1,3 @@
+({
+  array: ['1', '2', '3', '4']
+})
diff --git a/spec/_files/array_partial.mustache b/test/_files/partial_array.mustache
similarity index 100%
rename from spec/_files/array_partial.mustache
rename to test/_files/partial_array.mustache
diff --git a/spec/_files/array_partial.2.mustache b/test/_files/partial_array.partial
similarity index 83%
rename from spec/_files/array_partial.2.mustache
rename to test/_files/partial_array.partial
index 235dd5f..0ba652c 100644
--- a/spec/_files/array_partial.2.mustache
+++ b/test/_files/partial_array.partial
@@ -1,4 +1,4 @@
 Here's a non-sense array of values
 {{#array}}
   {{.}}
-{{/array}}
\ No newline at end of file
+{{/array}}
diff --git a/spec/_files/array_partial.txt b/test/_files/partial_array.txt
similarity index 98%
rename from spec/_files/array_partial.txt
rename to test/_files/partial_array.txt
index fd5f48e..892837c 100644
--- a/spec/_files/array_partial.txt
+++ b/test/_files/partial_array.txt
@@ -3,4 +3,3 @@ Here's a non-sense array of values
   2
   3
   4
-
diff --git a/test/_files/partial_array_of_partials.js b/test/_files/partial_array_of_partials.js
new file mode 100644
index 0000000..03f13c9
--- /dev/null
+++ b/test/_files/partial_array_of_partials.js
@@ -0,0 +1,8 @@
+({
+  numbers: [
+    {i: '1'},
+    {i: '2'},
+    {i: '3'},
+    {i: '4'}
+  ]
+})
diff --git a/spec/_files/array_of_partials_implicit_partial.mustache b/test/_files/partial_array_of_partials.mustache
similarity index 100%
rename from spec/_files/array_of_partials_implicit_partial.mustache
rename to test/_files/partial_array_of_partials.mustache
diff --git a/spec/_files/array_of_partials_partial.2.mustache b/test/_files/partial_array_of_partials.partial
similarity index 100%
rename from spec/_files/array_of_partials_partial.2.mustache
rename to test/_files/partial_array_of_partials.partial
diff --git a/spec/_files/array_of_partials_implicit_partial.txt b/test/_files/partial_array_of_partials.txt
similarity index 100%
rename from spec/_files/array_of_partials_implicit_partial.txt
rename to test/_files/partial_array_of_partials.txt
diff --git a/spec/_files/array_of_partials_implicit_partial.js b/test/_files/partial_array_of_partials_implicit.js
similarity index 53%
rename from spec/_files/array_of_partials_implicit_partial.js
rename to test/_files/partial_array_of_partials_implicit.js
index fcdf3b0..9ec0c00 100644
--- a/spec/_files/array_of_partials_implicit_partial.js
+++ b/test/_files/partial_array_of_partials_implicit.js
@@ -1,3 +1,3 @@
-var partial_context = { 
+({
   numbers: ['1', '2', '3', '4']
-};
+})
diff --git a/spec/_files/array_of_partials_partial.mustache b/test/_files/partial_array_of_partials_implicit.mustache
similarity index 100%
rename from spec/_files/array_of_partials_partial.mustache
rename to test/_files/partial_array_of_partials_implicit.mustache
diff --git a/spec/_files/array_of_partials_implicit_partial.2.mustache b/test/_files/partial_array_of_partials_implicit.partial
similarity index 100%
rename from spec/_files/array_of_partials_implicit_partial.2.mustache
rename to test/_files/partial_array_of_partials_implicit.partial
diff --git a/spec/_files/array_of_partials_partial.txt b/test/_files/partial_array_of_partials_implicit.txt
similarity index 100%
rename from spec/_files/array_of_partials_partial.txt
rename to test/_files/partial_array_of_partials_implicit.txt
diff --git a/test/_files/partial_empty.js b/test/_files/partial_empty.js
new file mode 100644
index 0000000..82b8c22
--- /dev/null
+++ b/test/_files/partial_empty.js
@@ -0,0 +1,3 @@
+({
+  foo: 1
+})
diff --git a/spec/_files/empty_partial.mustache b/test/_files/partial_empty.mustache
similarity index 100%
rename from spec/_files/empty_partial.mustache
rename to test/_files/partial_empty.mustache
diff --git a/test/_files/partial_empty.partial b/test/_files/partial_empty.partial
new file mode 100644
index 0000000..e69de29
diff --git a/spec/_files/empty_partial.txt b/test/_files/partial_empty.txt
similarity index 66%
rename from spec/_files/empty_partial.txt
rename to test/_files/partial_empty.txt
index 90d2b9f..1a67907 100644
--- a/spec/_files/empty_partial.txt
+++ b/test/_files/partial_empty.txt
@@ -1,2 +1 @@
 hey 1
-yo
diff --git a/test/_files/partial_template.js b/test/_files/partial_template.js
new file mode 100644
index 0000000..a913f87
--- /dev/null
+++ b/test/_files/partial_template.js
@@ -0,0 +1,6 @@
+({
+  title: function () {
+    return "Welcome";
+  },
+  again: "Goodbye"
+})
diff --git a/spec/_files/template_partial.mustache b/test/_files/partial_template.mustache
similarity index 59%
rename from spec/_files/template_partial.mustache
rename to test/_files/partial_template.mustache
index 6a09372..6a7492e 100644
--- a/spec/_files/template_partial.mustache
+++ b/test/_files/partial_template.mustache
@@ -1,2 +1,2 @@
 <h1>{{title}}</h1>
-{{>partial}}
\ No newline at end of file
+{{>partial}}
diff --git a/test/_files/partial_template.partial b/test/_files/partial_template.partial
new file mode 100644
index 0000000..a404529
--- /dev/null
+++ b/test/_files/partial_template.partial
@@ -0,0 +1 @@
+Again, {{again}}!
diff --git a/spec/_files/template_partial.txt b/test/_files/partial_template.txt
similarity index 100%
rename from spec/_files/template_partial.txt
rename to test/_files/partial_template.txt
diff --git a/test/_files/partial_view.js b/test/_files/partial_view.js
new file mode 100644
index 0000000..3ad70d3
--- /dev/null
+++ b/test/_files/partial_view.js
@@ -0,0 +1,14 @@
+({
+  greeting: function () {
+    return "Welcome";
+  },
+  farewell: function () {
+    return "Fair enough, right?";
+  },
+  name: "Chris",
+  value: 10000,
+  taxed_value: function () {
+    return this.value - (this.value * 0.4);
+  },
+  in_ca: true
+})
diff --git a/spec/_files/view_partial.mustache b/test/_files/partial_view.mustache
similarity index 61%
rename from spec/_files/view_partial.mustache
rename to test/_files/partial_view.mustache
index 8f0c08d..f8f6a5b 100644
--- a/spec/_files/view_partial.mustache
+++ b/test/_files/partial_view.mustache
@@ -1,3 +1,3 @@
 <h1>{{greeting}}</h1>
 {{>partial}}
-<h3>{{farewell}}</h3>
\ No newline at end of file
+<h3>{{farewell}}</h3>
diff --git a/spec/_files/simple.mustache b/test/_files/partial_view.partial
similarity index 100%
rename from spec/_files/simple.mustache
rename to test/_files/partial_view.partial
diff --git a/spec/_files/view_partial.txt b/test/_files/partial_view.txt
similarity index 99%
rename from spec/_files/view_partial.txt
rename to test/_files/partial_view.txt
index 160b0b6..c09147c 100644
--- a/spec/_files/view_partial.txt
+++ b/test/_files/partial_view.txt
@@ -2,5 +2,4 @@
 Hello Chris
 You have just won $10000!
 Well, $6000, after taxes.
-
 <h3>Fair enough, right?</h3>
diff --git a/test/_files/partial_whitespace.js b/test/_files/partial_whitespace.js
new file mode 100644
index 0000000..3ad70d3
--- /dev/null
+++ b/test/_files/partial_whitespace.js
@@ -0,0 +1,14 @@
+({
+  greeting: function () {
+    return "Welcome";
+  },
+  farewell: function () {
+    return "Fair enough, right?";
+  },
+  name: "Chris",
+  value: 10000,
+  taxed_value: function () {
+    return this.value - (this.value * 0.4);
+  },
+  in_ca: true
+})
diff --git a/spec/_files/whitespace_partial.mustache b/test/_files/partial_whitespace.mustache
similarity index 63%
rename from spec/_files/whitespace_partial.mustache
rename to test/_files/partial_whitespace.mustache
index ce43cb3..48bd1ff 100644
--- a/spec/_files/whitespace_partial.mustache
+++ b/test/_files/partial_whitespace.mustache
@@ -1,3 +1,3 @@
 <h1>{{  greeting  }}</h1>
 {{> partial }}
-<h3>{{ farewell }}</h3>
\ No newline at end of file
+<h3>{{ farewell }}</h3>
diff --git a/spec/_files/whitespace_partial.2.mustache b/test/_files/partial_whitespace.partial
similarity index 87%
rename from spec/_files/whitespace_partial.2.mustache
rename to test/_files/partial_whitespace.partial
index 9c46084..30de8f6 100644
--- a/spec/_files/whitespace_partial.2.mustache
+++ b/test/_files/partial_whitespace.partial
@@ -2,4 +2,4 @@ Hello {{ name}}
 You have just won ${{value }}!
 {{# in_ca  }}
 Well, ${{ taxed_value }}, after taxes.
-{{/  in_ca }}
+{{/  in_ca }}
\ No newline at end of file
diff --git a/spec/_files/whitespace_partial.txt b/test/_files/partial_whitespace.txt
similarity index 99%
rename from spec/_files/whitespace_partial.txt
rename to test/_files/partial_whitespace.txt
index 160b0b6..c09147c 100644
--- a/spec/_files/whitespace_partial.txt
+++ b/test/_files/partial_whitespace.txt
@@ -2,5 +2,4 @@
 Hello Chris
 You have just won $10000!
 Well, $6000, after taxes.
-
 <h3>Fair enough, right?</h3>
diff --git a/spec/_files/recursion_with_same_names.js b/test/_files/recursion_with_same_names.js
similarity index 56%
rename from spec/_files/recursion_with_same_names.js
rename to test/_files/recursion_with_same_names.js
index 5cceb08..ce26502 100644
--- a/spec/_files/recursion_with_same_names.js
+++ b/test/_files/recursion_with_same_names.js
@@ -1,8 +1,8 @@
-var recursion_with_same_names = {
+({
   name: 'name',
   description: 'desc',
   terms: [
     {name: 't1', index: 0},
-    {name: 't2', index: 1},
+    {name: 't2', index: 1}
   ]
-};
\ No newline at end of file
+})
diff --git a/spec/_files/recursion_with_same_names.mustache b/test/_files/recursion_with_same_names.mustache
similarity index 100%
rename from spec/_files/recursion_with_same_names.mustache
rename to test/_files/recursion_with_same_names.mustache
diff --git a/spec/_files/recursion_with_same_names.txt b/test/_files/recursion_with_same_names.txt
similarity index 96%
rename from spec/_files/recursion_with_same_names.txt
rename to test/_files/recursion_with_same_names.txt
index c23bb65..cb15d75 100644
--- a/spec/_files/recursion_with_same_names.txt
+++ b/test/_files/recursion_with_same_names.txt
@@ -1,5 +1,6 @@
 name
 desc
+
   t1
   0
   t2
diff --git a/test/_files/reuse_of_enumerables.js b/test/_files/reuse_of_enumerables.js
new file mode 100644
index 0000000..4368b57
--- /dev/null
+++ b/test/_files/reuse_of_enumerables.js
@@ -0,0 +1,6 @@
+({
+  terms: [
+    {name: 't1', index: 0},
+    {name: 't2', index: 1}
+  ]
+})
diff --git a/spec/_files/reuse_of_enumerables.mustache b/test/_files/reuse_of_enumerables.mustache
similarity index 100%
rename from spec/_files/reuse_of_enumerables.mustache
rename to test/_files/reuse_of_enumerables.mustache
diff --git a/spec/_files/reuse_of_enumerables.txt b/test/_files/reuse_of_enumerables.txt
similarity index 100%
rename from spec/_files/reuse_of_enumerables.txt
rename to test/_files/reuse_of_enumerables.txt
diff --git a/spec/_files/section_as_context.js b/test/_files/section_as_context.js
similarity index 53%
rename from spec/_files/section_as_context.js
rename to test/_files/section_as_context.js
index 81ca1be..425b29c 100644
--- a/spec/_files/section_as_context.js
+++ b/test/_files/section_as_context.js
@@ -1,7 +1,10 @@
-var section_as_context = {
+({
   a_object: {
     title: 'this is an object',
     description: 'one of its attributes is a list',
-    a_list: [{label: 'listitem1'}, {label: 'listitem2'}]
+    a_list: [
+      {label: 'listitem1'},
+      {label: 'listitem2'}
+    ]
   }
-};
+})
diff --git a/spec/_files/section_as_context.mustache b/test/_files/section_as_context.mustache
similarity index 100%
rename from spec/_files/section_as_context.mustache
rename to test/_files/section_as_context.mustache
diff --git a/spec/_files/section_as_context.txt b/test/_files/section_as_context.txt
similarity index 54%
rename from spec/_files/section_as_context.txt
rename to test/_files/section_as_context.txt
index 53ee336..d834e80 100644
--- a/spec/_files/section_as_context.txt
+++ b/test/_files/section_as_context.txt
@@ -1,6 +1,6 @@
   <h1>this is an object</h1>
   <p>one of its attributes is a list</p>
   <ul>
-        <li>listitem1</li>
-        <li>listitem2</li>
-    </ul>
+    <li>listitem1</li>
+    <li>listitem2</li>
+  </ul>
diff --git a/test/_files/section_functions_in_partials.js b/test/_files/section_functions_in_partials.js
new file mode 100644
index 0000000..4672778
--- /dev/null
+++ b/test/_files/section_functions_in_partials.js
@@ -0,0 +1,7 @@
+({
+  bold: function(){
+    return function(text, render) {
+      return "<b>" + render(text) + "</b>";
+    }
+  }
+})
diff --git a/test/_files/section_functions_in_partials.mustache b/test/_files/section_functions_in_partials.mustache
new file mode 100644
index 0000000..8164932
--- /dev/null
+++ b/test/_files/section_functions_in_partials.mustache
@@ -0,0 +1,3 @@
+{{> partial}}
+
+<p>some more text</p>
diff --git a/test/_files/section_functions_in_partials.partial b/test/_files/section_functions_in_partials.partial
new file mode 100644
index 0000000..3e90b00
--- /dev/null
+++ b/test/_files/section_functions_in_partials.partial
@@ -0,0 +1 @@
+{{#bold}}Hello There{{/bold}}
diff --git a/test/_files/section_functions_in_partials.txt b/test/_files/section_functions_in_partials.txt
new file mode 100644
index 0000000..2f5955c
--- /dev/null
+++ b/test/_files/section_functions_in_partials.txt
@@ -0,0 +1,3 @@
+<b>Hello There</b>
+
+<p>some more text</p>
diff --git a/spec/_files/simple.js b/test/_files/simple.js
similarity index 67%
rename from spec/_files/simple.js
rename to test/_files/simple.js
index 30f9834..1d8d6f4 100644
--- a/spec/_files/simple.js
+++ b/test/_files/simple.js
@@ -1,8 +1,8 @@
-var simple = {
+({
   name: "Chris",
   value: 10000,
-  taxed_value: function() {
+  taxed_value: function () {
     return this.value - (this.value * 0.4);
   },
   in_ca: true
-};
+})
diff --git a/spec/_files/view_partial.2.mustache b/test/_files/simple.mustache
similarity index 100%
rename from spec/_files/view_partial.2.mustache
rename to test/_files/simple.mustache
diff --git a/spec/_files/simple.txt b/test/_files/simple.txt
similarity index 100%
rename from spec/_files/simple.txt
rename to test/_files/simple.txt
diff --git a/test/_files/string_as_context.js b/test/_files/string_as_context.js
new file mode 100644
index 0000000..e8bb4da
--- /dev/null
+++ b/test/_files/string_as_context.js
@@ -0,0 +1,4 @@
+({
+  a_string: 'aa',
+  a_list: ['a','b','c']
+})
diff --git a/test/_files/string_as_context.mustache b/test/_files/string_as_context.mustache
new file mode 100644
index 0000000..00f7181
--- /dev/null
+++ b/test/_files/string_as_context.mustache
@@ -0,0 +1,5 @@
+<ul>
+{{#a_list}}
+  <li>{{a_string}}/{{.}}</li>
+{{/a_list}}
+</ul>
\ No newline at end of file
diff --git a/test/_files/string_as_context.txt b/test/_files/string_as_context.txt
new file mode 100644
index 0000000..8bd87ff
--- /dev/null
+++ b/test/_files/string_as_context.txt
@@ -0,0 +1,5 @@
+<ul>
+  <li>aa/a</li>
+  <li>aa/b</li>
+  <li>aa/c</li>
+</ul>
\ No newline at end of file
diff --git a/spec/_files/two_in_a_row.js b/test/_files/two_in_a_row.js
similarity index 60%
rename from spec/_files/two_in_a_row.js
rename to test/_files/two_in_a_row.js
index 09c1809..9c17c11 100644
--- a/spec/_files/two_in_a_row.js
+++ b/test/_files/two_in_a_row.js
@@ -1,4 +1,4 @@
-var two_in_a_row = {
+({
   name: "Joe",
   greeting: "Welcome"
-};
+})
diff --git a/test/_files/two_in_a_row.mustache b/test/_files/two_in_a_row.mustache
new file mode 100644
index 0000000..b23f29e
--- /dev/null
+++ b/test/_files/two_in_a_row.mustache
@@ -0,0 +1 @@
+{{greeting}}, {{name}}!
diff --git a/spec/_files/two_in_a_row.txt b/test/_files/two_in_a_row.txt
similarity index 100%
rename from spec/_files/two_in_a_row.txt
rename to test/_files/two_in_a_row.txt
diff --git a/test/_files/two_sections.js b/test/_files/two_sections.js
new file mode 100644
index 0000000..b4100a5
--- /dev/null
+++ b/test/_files/two_sections.js
@@ -0,0 +1 @@
+({})
diff --git a/spec/_files/two_sections.mustache b/test/_files/two_sections.mustache
similarity index 100%
rename from spec/_files/two_sections.mustache
rename to test/_files/two_sections.mustache
diff --git a/test/_files/two_sections.txt b/test/_files/two_sections.txt
new file mode 100644
index 0000000..e69de29
diff --git a/test/_files/unescaped.js b/test/_files/unescaped.js
new file mode 100644
index 0000000..0659b69
--- /dev/null
+++ b/test/_files/unescaped.js
@@ -0,0 +1,6 @@
+({
+  title: function () {
+    return "Bear > Shark";
+  },
+  symbol: null
+})
diff --git a/test/_files/unescaped.mustache b/test/_files/unescaped.mustache
new file mode 100644
index 0000000..1a27f58
--- /dev/null
+++ b/test/_files/unescaped.mustache
@@ -0,0 +1 @@
+<h1>{{{title}}}{{{symbol}}}</h1>
diff --git a/spec/_files/unescaped.txt b/test/_files/unescaped.txt
similarity index 100%
rename from spec/_files/unescaped.txt
rename to test/_files/unescaped.txt
diff --git a/test/_files/uses_props_from_view_prototype.js b/test/_files/uses_props_from_view_prototype.js
new file mode 100644
index 0000000..5fff76a
--- /dev/null
+++ b/test/_files/uses_props_from_view_prototype.js
@@ -0,0 +1,30 @@
+var Aaa = (function () {
+  function Aaa(x, y) {
+    this.x = x;
+    this._y = y;
+  }
+  Object.defineProperty(Aaa.prototype, "y", {
+    get: function () {
+      return this._y;
+    },
+    set: function (value) {
+      this._y = value;
+    },
+    enumerable: true,
+    configurable: true
+  });
+  return Aaa;
+})();
+var Bbb = (function () {
+  function Bbb() {
+  }
+  return Bbb;
+})();
+
+var b = new Bbb();
+b.item = new Aaa("0", "00");
+b.items = [];
+b.items.push({ a: new Aaa("1", "2") });
+b.items.push({ a: new Aaa("3", "4") });
+
+(b)
diff --git a/test/_files/uses_props_from_view_prototype.mustache b/test/_files/uses_props_from_view_prototype.mustache
new file mode 100644
index 0000000..874f0c9
--- /dev/null
+++ b/test/_files/uses_props_from_view_prototype.mustache
@@ -0,0 +1 @@
+[{{ item.x }};{{ item.y }}]||{{#items}}[{{ a.x }};{{ a.y }} {{#a}}{{y}}{{/a}}]{{/items}}
\ No newline at end of file
diff --git a/test/_files/uses_props_from_view_prototype.txt b/test/_files/uses_props_from_view_prototype.txt
new file mode 100644
index 0000000..f416840
--- /dev/null
+++ b/test/_files/uses_props_from_view_prototype.txt
@@ -0,0 +1 @@
+[0;00]||[1;2 2][3;4 4]
\ No newline at end of file
diff --git a/test/_files/whitespace.js b/test/_files/whitespace.js
new file mode 100644
index 0000000..f41cb56
--- /dev/null
+++ b/test/_files/whitespace.js
@@ -0,0 +1,4 @@
+({
+  tag1: "Hello",
+  tag2: "World"
+})
diff --git a/test/_files/whitespace.mustache b/test/_files/whitespace.mustache
new file mode 100644
index 0000000..aa76e08
--- /dev/null
+++ b/test/_files/whitespace.mustache
@@ -0,0 +1,4 @@
+{{tag1}}
+
+
+{{tag2}}.
diff --git a/test/_files/whitespace.txt b/test/_files/whitespace.txt
new file mode 100644
index 0000000..851fa74
--- /dev/null
+++ b/test/_files/whitespace.txt
@@ -0,0 +1,4 @@
+Hello
+
+
+World.
diff --git a/test/_files/zero_view.js b/test/_files/zero_view.js
new file mode 100644
index 0000000..9864608
--- /dev/null
+++ b/test/_files/zero_view.js
@@ -0,0 +1 @@
+({ nums: [0, 1, 2] })
diff --git a/test/_files/zero_view.mustache b/test/_files/zero_view.mustache
new file mode 100644
index 0000000..1cdc190
--- /dev/null
+++ b/test/_files/zero_view.mustache
@@ -0,0 +1 @@
+{{#nums}}{{.}},{{/nums}}
\ No newline at end of file
diff --git a/test/_files/zero_view.txt b/test/_files/zero_view.txt
new file mode 100644
index 0000000..2aee585
--- /dev/null
+++ b/test/_files/zero_view.txt
@@ -0,0 +1 @@
+0,1,2,
\ No newline at end of file
diff --git a/test/cli-test.js b/test/cli-test.js
new file mode 100644
index 0000000..1e78eea
--- /dev/null
+++ b/test/cli-test.js
@@ -0,0 +1,144 @@
+require('./helper');
+
+var fs = require('fs');
+var path = require('path');
+var child_process = require('child_process');
+var _files = path.join(__dirname, '_files');
+var cliTxt = path.resolve(_files, 'cli.txt');
+var cliPartialsTxt = path.resolve(_files, 'cli_with_partials.txt');
+var moduleVersion = require('../package').version;
+
+function changeForOS(command) {
+
+  if(process.platform === 'win32') {
+    return command
+      .replace(/bin\/mustache/g, 'node bin\\mustache')
+      .replace(/\bcat\b/g, 'type')
+      .replace(/\//g, '\\');
+  }
+
+  return command;
+}
+
+function exec() {
+  arguments[0] = changeForOS(arguments[0]);
+  return child_process.exec.apply(child_process, arguments);
+}
+
+describe('Mustache CLI', function () {
+
+  var expectedOutput;
+
+  it('writes syntax hints into stderr when runned with wrong number of arguments', function(done) {
+    exec('bin/mustache', function(err, stdout, stderr) {
+      assert.notEqual(stderr.indexOf('Syntax'), -1);
+      done();
+    });
+  });
+
+  it('writes hints about JSON parsing errors when given invalid JSON', function(done) {
+    exec('echo {name:"lebron"} | bin/mustache - test/_files/cli.mustache', function(err, stdout, stderr) {
+      assert.notEqual(stderr.indexOf('Shooot, could not parse view as JSON'), -1);
+      done();
+    });
+  });
+
+  it('writes module version into stdout when runned with --version', function(done){
+    exec('bin/mustache --version', function(err, stdout, stderr) {
+      assert.notEqual(stdout.indexOf(moduleVersion), -1);
+      done();
+    });
+  });
+
+  it('writes module version into stdout when runned with -v', function(done){
+    exec('bin/mustache -v', function(err, stdout, stderr) {
+      assert.notEqual(stdout.indexOf(moduleVersion), -1);
+      done();
+    });
+  });
+
+  describe("without partials", function(){
+    before(function(done) {
+      fs.readFile(cliTxt, function onFsEnd(err, data) {
+        if (err) return done(err);
+
+        expectedOutput = data.toString();
+        done();
+      });
+    });
+
+    it('writes rendered template into stdout when successfull', function(done) {
+      exec('bin/mustache test/_files/cli.json test/_files/cli.mustache', function(err, stdout, stderr) {
+        assert.equal(err, null);
+        assert.equal(stderr, '');
+        assert.equal(stdout, expectedOutput);
+        done();
+      });
+    });
+
+    it('writes rendered template into the file specified by the third argument', function(done) {
+      var outputFile = 'test/_files/cli_output.txt';
+      exec('bin/mustache test/_files/cli.json test/_files/cli.mustache ' + outputFile, function(err, stdout, stderr) {
+        assert.equal(err, null);
+        assert.equal(stderr, '');
+        assert.equal(stdout, '');
+        assert.equal(fs.readFileSync(outputFile), expectedOutput);
+        fs.unlink('test/_files/cli_output.txt');
+        done();
+      });
+    });
+
+    it('reads view data from stdin when first argument equals "-"', function(done){
+      exec('cat test/_files/cli.json | bin/mustache - test/_files/cli.mustache', function(err, stdout, stderr) {
+        assert.equal(err, null);
+        assert.equal(stderr, '');
+        assert.equal(stdout, expectedOutput);
+        done();
+      });
+    });
+
+    it('writes it couldnt find template into stderr when second argument doesnt resolve to a file', function(done) {
+      exec('bin/mustache test/_files/cli.json test/_files/non-existing-template.mustache', function(err, stdout, stderr) {
+        assert.isOk(/Could not find file: .+non-existing-template\.mustache/.test(stderr));
+        done();
+      });
+    });
+
+    it('writes it couldnt find view into stderr when first argument doesnt resolve to a file', function(done) {
+      exec('bin/mustache test/_files/non-existing-view.json test/_files/cli.mustache', function(err, stdout, stderr) {
+        assert.isOk(/Could not find file: .+non-existing-view\.json/.test(stderr));
+        done();
+      });
+    });
+  });
+
+
+  describe("with partials", function(){
+    before(function(done) {
+      fs.readFile(cliPartialsTxt, function onFsEnd(err, data) {
+        if (err) return done(err);
+
+        expectedOutput = data.toString();
+        done();
+      });
+    });
+
+    it('writes rendered template with partials into stdout', function(done) {
+      exec('bin/mustache test/_files/cli_with_partials.json test/_files/cli_with_partials.mustache -p test/_files/cli.mustache -p test/_files/comments.mustache', function(err, stdout, stderr) {
+        assert.equal(err, null);
+        assert.equal(stderr, '');
+        assert.equal(stdout, expectedOutput);
+        done();
+      });
+    });
+
+    it('writes rendered template with partials when partials args before required args', function(done) {
+      exec('bin/mustache -p test/_files/cli.mustache -p test/_files/comments.mustache test/_files/cli_with_partials.json test/_files/cli_with_partials.mustache', function(err, stdout, stderr) {
+        assert.equal(err, null);
+        assert.equal(stderr, '');
+        assert.equal(stdout, expectedOutput);
+        done();
+      });
+    });
+  })
+});
diff --git a/test/context-test.js b/test/context-test.js
new file mode 100644
index 0000000..9b9cbbe
--- /dev/null
+++ b/test/context-test.js
@@ -0,0 +1,61 @@
+require('./helper');
+var Context = Mustache.Context;
+
+describe('A new Mustache.Context', function () {
+  var context;
+  beforeEach(function () {
+    context = new Context({ name: 'parent', message: 'hi', a: { b: 'b' } });
+  });
+
+  it('is able to lookup properties of its own view', function () {
+    assert.equal(context.lookup('name'), 'parent');
+  });
+
+  it('is able to lookup nested properties of its own view', function () {
+    assert.equal(context.lookup('a.b'), 'b');
+  });
+
+  describe('when pushed', function () {
+    beforeEach(function () {
+      context = context.push({ name: 'child', c: { d: 'd' } });
+    });
+
+    it('returns the child context', function () {
+      assert.equal(context.view.name, 'child');
+      assert.equal(context.parent.view.name, 'parent');
+    });
+
+    it('is able to lookup properties of its own view', function () {
+      assert.equal(context.lookup('name'), 'child');
+    });
+
+    it("is able to lookup properties of the parent context's view", function () {
+      assert.equal(context.lookup('message'), 'hi');
+    });
+
+    it('is able to lookup nested properties of its own view', function () {
+      assert.equal(context.lookup('c.d'), 'd');
+    });
+
+    it('is able to lookup nested properties of its parent view', function () {
+      assert.equal(context.lookup('a.b'), 'b');
+    });
+  });
+});
+
+describe('A Mustache.Context', function () {
+  var context;
+
+  describe('with an empty string in the lookup chain', function () {
+    var view, context;
+    beforeEach(function () {
+      view = { a: '' };
+      view.a.b = 'value';
+      context = new Context(view);
+    });
+
+    it('is able to lookup a nested property', function () {
+      assert.equal(context.lookup('a.b'), view.a.b);
+    });
+  });
+});
diff --git a/test/create-browser-suite.js b/test/create-browser-suite.js
new file mode 100644
index 0000000..0f23da6
--- /dev/null
+++ b/test/create-browser-suite.js
@@ -0,0 +1,14 @@
+require('./helper');
+
+var renderHelper = require('./render-helper');
+
+var fs = require('fs');
+var path = require('path');
+
+var _testsTemplate = path.join(__dirname, 'render-test-browser-tmpl.mustache');
+var _templateContent = fs.readFileSync(_testsTemplate).toString();
+
+var tests = renderHelper.getTests();
+var content = Mustache.render(_templateContent, JSON.stringify(tests));
+
+fs.writeFileSync(path.join(__dirname, 'render-test-browser.js'), content);
\ No newline at end of file
diff --git a/test/helper.js b/test/helper.js
new file mode 100644
index 0000000..2988766
--- /dev/null
+++ b/test/helper.js
@@ -0,0 +1,4 @@
+var chai = require('chai');
+assert = chai.assert;
+chai.should();
+Mustache = require('../mustache');
diff --git a/test/mustache-spec-test.js b/test/mustache-spec-test.js
new file mode 100644
index 0000000..0c6e537
--- /dev/null
+++ b/test/mustache-spec-test.js
@@ -0,0 +1,89 @@
+require('./helper');
+
+var fs = require('fs');
+var path = require('path');
+var specsDir = path.join(__dirname, 'spec/specs');
+
+var skipTests = {
+  comments: [
+    'Standalone Without Newline'
+  ],
+  delimiters: [
+    'Standalone Without Newline'
+  ],
+  inverted: [
+    'Standalone Without Newline'
+  ],
+  partials: [
+    'Standalone Without Previous Line',
+    'Standalone Without Newline',
+    'Standalone Indentation'
+  ],
+  sections: [
+    'Standalone Without Newline'
+  ],
+  '~lambdas': [
+    'Interpolation',
+    'Interpolation - Expansion',
+    'Interpolation - Alternate Delimiters',
+    'Interpolation - Multiple Calls',
+    'Escaping',
+    'Section - Expansion',
+    'Section - Alternate Delimiters'
+  ]
+};
+
+// You can run the skiped tests by setting the NOSKIP environment variable to
+// true (e.g. NOSKIP=true mocha test/mustache-spec-test.js)
+var noSkip = process.env.NOSKIP;
+
+// You can put the name of a specific test file to run in the TEST environment
+// variable (e.g. TEST=interpolation mocha test/mustache-spec-test.js)
+var fileToRun = process.env.TEST;
+
+// Mustache should work on node 0.6 that doesn't have fs.existsSync
+function existsDir(path) {
+  try {
+    return fs.statSync(path).isDirectory();
+  } catch (x) {
+    return false;
+  }
+}
+
+var specFiles;
+if (fileToRun) {
+  specFiles = [fileToRun];
+} else if (existsDir(specsDir)) {
+  specFiles = fs.readdirSync(specsDir).filter(function (file) {
+    return (/\.json$/).test(file);
+  }).map(function (file) {
+    return path.basename(file).replace(/\.json$/, '');
+  }).sort();
+} else {
+  specFiles = [];
+}
+
+function getSpecs(specArea) {
+  return JSON.parse(fs.readFileSync(path.join(specsDir, specArea + '.' + 'json'), 'utf8'));
+}
+
+describe('Mustache spec compliance', function() {
+  beforeEach(function () {
+    Mustache.clearCache();
+  });
+
+  specFiles.forEach(function(specArea) {
+    describe('- ' + specArea + ':', function() {
+      var specs = getSpecs(specArea);
+      specs.tests.forEach(function(test) {
+        var it_ = (!noSkip && skipTests[specArea] && skipTests[specArea].indexOf(test.name) >= 0) ? it.skip : it;
+        it_(test.name + ' - ' + test.desc, function() {
+          if (test.data.lambda && test.data.lambda.__tag__ === 'code')
+            test.data.lambda = eval('(function() { return ' + test.data.lambda.js + '; })');
+          var output = Mustache.render(test.template, test.data, test.partials);
+          assert.equal(output, test.expected);
+        });
+      });
+    });
+  });
+});
diff --git a/test/parse-test.js b/test/parse-test.js
new file mode 100644
index 0000000..97c26db
--- /dev/null
+++ b/test/parse-test.js
@@ -0,0 +1,106 @@
+require('./helper');
+
+// A map of templates to their expected token output. Tokens are in the format:
+// [type, value, startIndex, endIndex, subTokens].
+var expectations = {
+  ''                                        : [],
+  '{{hi}}'                                  : [ [ 'name', 'hi', 0, 6 ] ],
+  '{{hi.world}}'                            : [ [ 'name', 'hi.world', 0, 12 ] ],
+  '{{hi . world}}'                          : [ [ 'name', 'hi . world', 0, 14 ] ],
+  '{{ hi}}'                                 : [ [ 'name', 'hi', 0, 7 ] ],
+  '{{hi }}'                                 : [ [ 'name', 'hi', 0, 7 ] ],
+  '{{ hi }}'                                : [ [ 'name', 'hi', 0, 8 ] ],
+  '{{{hi}}}'                                : [ [ '&', 'hi', 0, 8 ] ],
+  '{{!hi}}'                                 : [ [ '!', 'hi', 0, 7 ] ],
+  '{{! hi}}'                                : [ [ '!', 'hi', 0, 8 ] ],
+  '{{! hi }}'                               : [ [ '!', 'hi', 0, 9 ] ],
+  '{{ !hi}}'                                : [ [ '!', 'hi', 0, 8 ] ],
+  '{{ ! hi}}'                               : [ [ '!', 'hi', 0, 9 ] ],
+  '{{ ! hi }}'                              : [ [ '!', 'hi', 0, 10 ] ],
+  'a\n b'                                   : [ [ 'text', 'a\n b', 0, 4 ] ],
+  'a{{hi}}'                                 : [ [ 'text', 'a', 0, 1 ], [ 'name', 'hi', 1, 7 ] ],
+  'a {{hi}}'                                : [ [ 'text', 'a ', 0, 2 ], [ 'name', 'hi', 2, 8 ] ],
+  ' a{{hi}}'                                : [ [ 'text', ' a', 0, 2 ], [ 'name', 'hi', 2, 8 ] ],
+  ' a {{hi}}'                               : [ [ 'text', ' a ', 0, 3 ], [ 'name', 'hi', 3, 9 ] ],
+  'a{{hi}}b'                                : [ [ 'text', 'a', 0, 1 ], [ 'name', 'hi', 1, 7 ], [ 'text', 'b', 7, 8 ] ],
+  'a{{hi}} b'                               : [ [ 'text', 'a', 0, 1 ], [ 'name', 'hi', 1, 7 ], [ 'text', ' b', 7, 9 ] ],
+  'a{{hi}}b '                               : [ [ 'text', 'a', 0, 1 ], [ 'name', 'hi', 1, 7 ], [ 'text', 'b ', 7, 9 ] ],
+  'a\n{{hi}} b \n'                          : [ [ 'text', 'a\n', 0, 2 ], [ 'name', 'hi', 2, 8 ], [ 'text', ' b \n', 8, 12 ] ],
+  'a\n {{hi}} \nb'                          : [ [ 'text', 'a\n ', 0, 3 ], [ 'name', 'hi', 3, 9 ], [ 'text', ' \nb', 9, 12 ] ],
+  'a\n {{!hi}} \nb'                         : [ [ 'text', 'a\n', 0, 2 ], [ '!', 'hi', 3, 10 ], [ 'text', 'b', 12, 13 ] ],
+  'a\n{{#a}}{{/a}}\nb'                      : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 2, 8, [], 8 ], [ 'text', 'b', 15, 16 ] ],
+  'a\n {{#a}}{{/a}}\nb'                     : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 9 ], [ 'text', 'b', 16, 17 ] ],
+  'a\n {{#a}}{{/a}} \nb'                    : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 9 ], [ 'text', 'b', 17, 18 ] ],
+  'a\n{{#a}}\n{{/a}}\nb'                    : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 2, 8, [], 9 ], [ 'text', 'b', 16, 17 ] ],
+  'a\n {{#a}}\n{{/a}}\nb'                   : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 10 ], [ 'text', 'b', 17, 18 ] ],
+  'a\n {{#a}}\n{{/a}} \nb'                  : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 10 ], [ 'text', 'b', 18, 19 ] ],
+  'a\n{{#a}}\n{{/a}}\n{{#b}}\n{{/b}}\nb'    : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 2, 8, [], 9 ], [ '#', 'b', 16, 22, [], 23 ], [ 'text', 'b', 30, 31 ] ],
+  'a\n {{#a}}\n{{/a}}\n{{#b}}\n{{/b}}\nb'   : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 10 ], [ '#', 'b', 17, 23, [], 24 ], [ 'text', 'b', 31, 32 ] ],
+  'a\n {{#a}}\n{{/a}}\n{{#b}}\n{{/b}} \nb'  : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [], 10 ], [ '#', 'b', 17, 23, [], 24 ], [ 'text', 'b', 32, 33 ] ],
+  'a\n{{#a}}\n{{#b}}\n{{/b}}\n{{/a}}\nb'    : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 2, 8, [ [ '#', 'b', 9, 15, [], 16 ] ], 23 ], [ 'text', 'b', 30, 31 ] ],
+  'a\n {{#a}}\n{{#b}}\n{{/b}}\n{{/a}}\nb'   : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [ [ '#', 'b', 10, 16, [], 17 ] ], 24 ], [ 'text', 'b', 31, 32 ] ],
+  'a\n {{#a}}\n{{#b}}\n{{/b}}\n{{/a}} \nb'  : [ [ 'text', 'a\n', 0, 2 ], [ '#', 'a', 3, 9, [ [ '#', 'b', 10, 16, [], 17 ] ], 24 ], [ 'text', 'b', 32, 33 ] ],
+  '{{>abc}}'                                : [ [ '>', 'abc', 0, 8 ] ],
+  '{{> abc }}'                              : [ [ '>', 'abc', 0, 10 ] ],
+  '{{ > abc }}'                             : [ [ '>', 'abc', 0, 11 ] ],
+  '{{=<% %>=}}'                             : [ [ '=', '<% %>', 0, 11 ] ],
+  '{{= <% %> =}}'                           : [ [ '=', '<% %>', 0, 13 ] ],
+  '{{=<% %>=}}<%={{ }}=%>'                  : [ [ '=', '<% %>', 0, 11 ], [ '=', '{{ }}', 11, 22 ] ],
+  '{{=<% %>=}}<%hi%>'                       : [ [ '=', '<% %>', 0, 11 ], [ 'name', 'hi', 11, 17 ] ],
+  '{{#a}}{{/a}}hi{{#b}}{{/b}}\n'            : [ [ '#', 'a', 0, 6, [], 6 ], [ 'text', 'hi', 12, 14 ], [ '#', 'b', 14, 20, [], 20 ], [ 'text', '\n', 26, 27 ] ],
+  '{{a}}\n{{b}}\n\n{{#c}}\n{{/c}}\n'        : [ [ 'name', 'a', 0, 5 ], [ 'text', '\n', 5, 6 ], [ 'name', 'b', 6, 11 ], [ 'text', '\n\n', 11, 13 ], [ '#', 'c', 13, 19, [], 20 ] ],
+  '{{#foo}}\n  {{#a}}\n    {{b}}\n  {{/a}}\n{{/foo}}\n'
+                                            : [ [ '#', 'foo', 0, 8, [ [ '#', 'a', 11, 17, [ [ 'text', '    ', 18, 22 ], [ 'name', 'b', 22, 27 ], [ 'text', '\n', 27, 28 ] ], 30 ] ], 37 ] ]
+};
+
+describe('Mustache.parse', function () {
+
+  for (var template in expectations) {
+    (function (template, tokens) {
+      it('knows how to parse ' + JSON.stringify(template), function () {
+        assert.deepEqual(Mustache.parse(template), tokens);
+      });
+    })(template, expectations[template]);
+  }
+
+  describe('when there is an unclosed tag', function () {
+    it('throws an error', function () {
+      assert.throws(function () {
+        Mustache.parse('My name is {{name');
+      }, /unclosed tag at 17/i);
+    });
+  });
+
+  describe('when there is an unclosed section', function () {
+    it('throws an error', function () {
+      assert.throws(function () {
+        Mustache.parse('A list: {{#people}}{{name}}');
+      }, /unclosed section "people" at 27/i);
+    });
+  });
+
+  describe('when there is an unopened section', function () {
+    it('throws an error', function () {
+      assert.throws(function () {
+        Mustache.parse('The end of the list! {{/people}}');
+      }, /unopened section "people" at 21/i);
+    });
+  });
+
+  describe('when invalid tags are given as an argument', function () {
+    it('throws an error', function () {
+      assert.throws(function () {
+        Mustache.parse('A template <% name %>', [ '<%' ]);
+      }, /invalid tags/i);
+    });
+  });
+
+  describe('when the template contains invalid tags', function () {
+    it('throws an error', function () {
+      assert.throws(function () {
+        Mustache.parse('A template {{=<%=}}');
+      }, /invalid tags/i);
+    });
+  });
+
+});
diff --git a/test/render-helper.js b/test/render-helper.js
new file mode 100644
index 0000000..11e73c9
--- /dev/null
+++ b/test/render-helper.js
@@ -0,0 +1,55 @@
+var fs = require('fs');
+var path = require('path');
+
+var _files = path.join(__dirname, '_files');
+
+function getContents(testName, ext) {
+  try {
+    return fs.readFileSync(path.join(_files, testName + '.' + ext), 'utf8');
+  } catch (ex) {
+    return null;
+  }
+}
+
+function getView(testName) {
+  var view = getContents(testName, 'js');
+  if (!view) throw new Error('Cannot find view for test "' + testName + '"');
+  return view;
+}
+
+function getPartial(testName) {
+  try {
+    return getContents(testName, 'partial');
+  } catch (error) {
+    // No big deal. Not all tests need to test partial support.
+  }
+}
+
+// You can put the name of a specific test to run in the TEST environment
+// variable (e.g. TEST=backslashes mocha test/render-test.js)
+var testToRun = process.env.TEST;
+
+var testNames;
+if (testToRun) {
+  testNames = testToRun.split(',');
+} else {
+  testNames = fs.readdirSync(_files).filter(function (file) {
+    return (/\.js$/).test(file);
+  }).map(function (file) {
+    return path.basename(file).replace(/\.js$/, '');
+  });
+}
+
+function getTest(testName) {
+  return {
+    name: testName,
+    view: getView(testName),
+    template: getContents(testName, 'mustache'),
+    partial: getPartial(testName),
+    expect: getContents(testName, 'txt')
+  };
+}
+
+exports.getTests = function getTests() {
+  return testNames.map(getTest);
+};
\ No newline at end of file
diff --git a/test/render-test-browser-tmpl.mustache b/test/render-test-browser-tmpl.mustache
new file mode 100644
index 0000000..8083891
--- /dev/null
+++ b/test/render-test-browser-tmpl.mustache
@@ -0,0 +1,38 @@
+require('./helper');
+
+describe('Mustache.render', function () {
+  beforeEach(function () {
+    Mustache.clearCache();
+  });
+
+  it('requires template to be a string', function () {
+    assert.throws(function () {
+      Mustache.render(['dummy template'], ['foo', 'bar']);
+    }, TypeError, 'Invalid template! Template should be a "string" but ' +
+                  '"array" was given as the first argument ' +
+                  'for mustache#render(template, view, partials)');
+  });
+
+  var i;
+  var tests = {{{.}}};
+
+  for (i = 0; i < tests.length; i++) {
+
+    (function indexClosure(test) {
+        var view = eval(test.view);
+
+        it('knows how to render ' + test.name, function () {
+
+          var output;
+          if (test.partial) {
+            output = Mustache.render(test.template, view, { partial: test.partial });
+          } else {
+            output = Mustache.render(test.template, view);
+          }
+
+          assert.equal(output, test.expect);
+        });
+    })(tests[i]);
+
+  }
+});
\ No newline at end of file
diff --git a/test/render-test.js b/test/render-test.js
new file mode 100644
index 0000000..e9d61a9
--- /dev/null
+++ b/test/render-test.js
@@ -0,0 +1,35 @@
+require('./helper');
+
+var renderHelper = require('./render-helper');
+
+var tests = renderHelper.getTests();
+
+describe('Mustache.render', function () {
+  beforeEach(function () {
+    Mustache.clearCache();
+  });
+
+  it('requires template to be a string', function () {
+    assert.throws(function () {
+      Mustache.render(['dummy template'], ['foo', 'bar']);
+    }, TypeError, 'Invalid template! Template should be a "string" but ' +
+                  '"array" was given as the first argument ' +
+                  'for mustache#render(template, view, partials)');
+  });
+
+  tests.forEach(function (test) {
+    var view = eval(test.view);
+
+    it('knows how to render ' + test.name, function () {
+      var output;
+      if (test.partial) {
+        output = Mustache.render(test.template, view, { partial: test.partial });
+      } else {
+        output = Mustache.render(test.template, view);
+      }
+
+      output.should.equal(test.expect);
+    });
+
+  });
+});
diff --git a/test/scanner-test.js b/test/scanner-test.js
new file mode 100644
index 0000000..9c97664
--- /dev/null
+++ b/test/scanner-test.js
@@ -0,0 +1,78 @@
+require('./helper');
+var Scanner = Mustache.Scanner;
+
+describe('A new Mustache.Scanner', function () {
+  describe('for an empty string', function () {
+    it('is at the end', function () {
+      var scanner = new Scanner('');
+      assert(scanner.eos());
+    });
+  });
+
+  describe('for a non-empty string', function () {
+    var scanner;
+    beforeEach(function () {
+      scanner = new Scanner('a b c');
+    });
+
+    describe('scan', function () {
+      describe('when the RegExp matches the entire string', function () {
+        it('returns the entire string', function () {
+          var match = scanner.scan(/a b c/);
+          assert.equal(match, scanner.string);
+          assert(scanner.eos());
+        });
+      });
+
+      describe('when the RegExp matches at index 0', function () {
+        it('returns the portion of the string that matched', function () {
+          var match = scanner.scan(/a/);
+          assert.equal(match, 'a');
+          assert.equal(scanner.pos, 1);
+        });
+      });
+
+      describe('when the RegExp matches at some index other than 0', function () {
+        it('returns the empty string', function () {
+          var match = scanner.scan(/b/);
+          assert.equal(match, '');
+          assert.equal(scanner.pos, 0);
+        });
+      });
+
+      describe('when the RegExp does not match', function () {
+        it('returns the empty string', function () {
+          var match = scanner.scan(/z/);
+          assert.equal(match, '');
+          assert.equal(scanner.pos, 0);
+        });
+      });
+    }); // scan
+
+    describe('scanUntil', function () {
+      describe('when the RegExp matches at index 0', function () {
+        it('returns the empty string', function () {
+          var match = scanner.scanUntil(/a/);
+          assert.equal(match, '');
+          assert.equal(scanner.pos, 0);
+        });
+      });
+
+      describe('when the RegExp matches at some index other than 0', function () {
+        it('returns the string up to that index', function () {
+          var match = scanner.scanUntil(/b/);
+          assert.equal(match, 'a ');
+          assert.equal(scanner.pos, 2);
+        });
+      });
+
+      describe('when the RegExp does not match', function () {
+        it('returns the entire string', function () {
+          var match = scanner.scanUntil(/z/);
+          assert.equal(match, scanner.string);
+          assert(scanner.eos());
+        });
+      });
+    }); // scanUntil
+  }); // for a non-empty string
+});
diff --git a/wrappers/commonjs/mustache.js.tpl.post b/wrappers/commonjs/mustache.js.tpl.post
deleted file mode 100644
index f566443..0000000
--- a/wrappers/commonjs/mustache.js.tpl.post
+++ /dev/null
@@ -1,8 +0,0 @@
-if (typeof module !== 'undefined' && module.exports) {
-    exports.name = Mustache.name;
-    exports.version = Mustache.version;
-
-    exports.to_html = function() {
-      return Mustache.to_html.apply(this, arguments);
-    };
-}
diff --git a/wrappers/commonjs/mustache.js.tpl.pre b/wrappers/commonjs/mustache.js.tpl.pre
deleted file mode 100644
index 5e33b34..0000000
--- a/wrappers/commonjs/mustache.js.tpl.pre
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
- * CommonJS-compatible mustache.js module
- *
- * See http://github.com/janl/mustache.js for more info.
- */
-
diff --git a/wrappers/commonjs/package.json b/wrappers/commonjs/package.json
deleted file mode 100644
index 8e13993..0000000
--- a/wrappers/commonjs/package.json
+++ /dev/null
@@ -1,8 +0,0 @@
-{
-    "name": "mustache",
-    "author": "http://mustache.github.com/",
-    "description": "Logic-less {{mustache}} templates with JavaScript",
-    "keywords": ["template", "templates", "mustache"],
-    "version": "{{version}}",
-    "main": "./mustache"
-}
diff --git a/wrappers/dojo/mustache.js.post b/wrappers/dojo/mustache.js.post
new file mode 100644
index 0000000..eeeb4b7
--- /dev/null
+++ b/wrappers/dojo/mustache.js.post
@@ -0,0 +1,4 @@
+
+  dojox.mustache = dojo.hitch(Mustache, "render");
+
+})();
\ No newline at end of file
diff --git a/wrappers/dojo/mustache.js.tpl.pre b/wrappers/dojo/mustache.js.pre
similarity index 100%
rename from wrappers/dojo/mustache.js.tpl.pre
rename to wrappers/dojo/mustache.js.pre
diff --git a/wrappers/dojo/mustache.js.tpl.post b/wrappers/dojo/mustache.js.tpl.post
deleted file mode 100644
index d64667f..0000000
--- a/wrappers/dojo/mustache.js.tpl.post
+++ /dev/null
@@ -1,4 +0,0 @@
-
-  dojox.mustache = dojo.hitch(Mustache, "to_html");
-
-})();
\ No newline at end of file
diff --git a/wrappers/jquery/jquery.mustache.js.tpl.post b/wrappers/jquery/jquery.mustache.js.tpl.post
deleted file mode 100644
index 1fe2887..0000000
--- a/wrappers/jquery/jquery.mustache.js.tpl.post
+++ /dev/null
@@ -1,6 +0,0 @@
-
-  $.mustache = function(template, view, partials) {
-    return Mustache.to_html(template, view, partials);
-  };
-
-})(jQuery);
diff --git a/wrappers/jquery/mustache.js.post b/wrappers/jquery/mustache.js.post
new file mode 100644
index 0000000..3209e91
--- /dev/null
+++ b/wrappers/jquery/mustache.js.post
@@ -0,0 +1,13 @@
+  $.mustache = function (template, view, partials) {
+    return Mustache.render(template, view, partials);
+  };
+
+  $.fn.mustache = function (view, partials) {
+    return $(this).map(function (i, elm) {
+      var template = $.trim($(elm).html());
+      var output = $.mustache(template, view, partials);
+      return $(output).get();
+    });
+  };
+
+})(jQuery);
diff --git a/wrappers/jquery/jquery.mustache.js.tpl.pre b/wrappers/jquery/mustache.js.pre
similarity index 100%
rename from wrappers/jquery/jquery.mustache.js.tpl.pre
rename to wrappers/jquery/mustache.js.pre
diff --git a/wrappers/mootools/mustache.js.post b/wrappers/mootools/mustache.js.post
new file mode 100644
index 0000000..aa9b8fa
--- /dev/null
+++ b/wrappers/mootools/mustache.js.post
@@ -0,0 +1,5 @@
+
+    Object.implement('mustache', function(view, partials){
+        return Mustache.render(view, this, partials);
+    });
+})();
diff --git a/wrappers/mootools/mustache.js.pre b/wrappers/mootools/mustache.js.pre
new file mode 100644
index 0000000..9839f99
--- /dev/null
+++ b/wrappers/mootools/mustache.js.pre
@@ -0,0 +1,2 @@
+(function(){
+
diff --git a/wrappers/qooxdoo/mustache.js.post b/wrappers/qooxdoo/mustache.js.post
new file mode 100644
index 0000000..6488b9c
--- /dev/null
+++ b/wrappers/qooxdoo/mustache.js.post
@@ -0,0 +1,9 @@
+/**
+ * Above is the original mustache code.
+ */
+
+// EXPOSE qooxdoo variant
+qx.bom.Template.version = this.Mustache.version;
+qx.bom.Template.render = this.Mustache.render;
+
+}).call({});
\ No newline at end of file
diff --git a/wrappers/qooxdoo/qooxdoo.mustache.js.tpl.pre b/wrappers/qooxdoo/mustache.js.pre
similarity index 58%
rename from wrappers/qooxdoo/qooxdoo.mustache.js.tpl.pre
rename to wrappers/qooxdoo/mustache.js.pre
index f7d1014..1512a00 100644
--- a/wrappers/qooxdoo/qooxdoo.mustache.js.tpl.pre
+++ b/wrappers/qooxdoo/mustache.js.pre
@@ -5,7 +5,7 @@
    http://qooxdoo.org
 
    Copyright:
-     2004-2011 1&1 Internet AG, Germany, http://www.1und1.de
+     2004-2012 1&1 Internet AG, Germany, http://www.1und1.de
 
    License:
      LGPL: http://www.gnu.org/licenses/lgpl.html
@@ -19,7 +19,7 @@
 
    This class contains code based on the following work:
 
-   * Mustache.js version 0.4.2
+   * Mustache.js version 0.8.0
 
      Code:
        https://github.com/janl/mustache.js
@@ -58,23 +58,25 @@
 ************************************************************************ */
 
 /**
- * The is a template class which can be used for HTML templating. In fact, 
- * this is a wrapper for mustache.js which is a "framework-agnostic way to 
+ * The is a template class which can be used for HTML templating. In fact,
+ * this is a wrapper for mustache.js which is a "framework-agnostic way to
  * render logic-free views".
- * 
+ *
  * Here is a basic example how to use it:
  * Template:
- * <pre>
+ * <pre class="javascript">
  * var template = "Hi, my name is {{name}}!";
  * var view = {name: "qooxdoo"};
- * qx.bom.Template.toHtml(template, view);
+ * qx.bom.Template.render(template, view);
  * // return "Hi, my name is qooxdoo!"
  * </pre>
- * 
+ *
  * For further details, please visit the mustache.js documentation here:
  *   https://github.com/janl/mustache.js/blob/master/README.md
+ *
+ * @ignore(module)
  */
-qx.Class.define("qx.bom.Template", {
+qx.Bootstrap.define("qx.bom.Template", {
   statics : {
     /** Contains the mustache.js version. */
     version: null,
@@ -83,45 +85,88 @@ qx.Class.define("qx.bom.Template", {
      * Original and only template method of mustache.js. For further
      * documentation, please visit https://github.com/janl/mustache.js
      *
-     * @signature function(template, view, partials, send_fun)
+     * @signature function(template, view, partials)
      * @param template {String} The String containing the template.
      * @param view {Object} The object holding the data to render.
      * @param partials {Object} Object holding parts of a template.
-     * @param send_fun {Function?} Callback function for streaming.
      * @return {String} The parsed template.
      */
-    toHtml: null,
+    render: null,
 
+    /**
+     * Combines {@link #render} and {@link #get}. Input is equal to {@link #render}
+     * and output is equal to {@link #get}. The advantage over {@link #get}
+     * is that you don't need a HTML template but can use a template
+     * string and still get a DOM element. Keep in mind that templates
+     * can only have one root element.
+     *
+     * @param template {String} The String containing the template.
+     * @param view {Object} The object holding the data to render.
+     * @param partials {Object} Object holding parts of a template.
+     * @return {Element} A DOM element holding the parsed template data.
+     */
+    renderToNode : function(template, view, partials) {
+       var renderedTmpl = this.render(template, view, partials);
+       return this._createNodeFromTemplate(renderedTmpl);
+    },
 
     /**
-     * Helper method which provides you with a direct access to templates 
-     * stored as HTML in the DOM. The DOM node with the given ID will be reated 
-     * as a template, parsed and a new DOM node will be returned containing the 
-     * parsed data.
+     * Helper method which provides you with a direct access to templates
+     * stored as HTML in the DOM. The DOM node with the given ID will be used
+     * as a template, parsed and a new DOM node will be returned containing the
+     * parsed data. Keep in mind to have only one root DOM element in the the
+     * template.
+     * Additionally, you should not put the template into a regular, hidden
+     * DOM element because the template may not be valid HTML due to the containing
+     * mustache tags. We suggest to put it into a script tag with the type
+     * <code>text/template</code>.
      *
      * @param id {String} The id of the HTML template in the DOM.
      * @param view {Object} The object holding the data to render.
      * @param partials {Object} Object holding parts of a template.
-     * @return {DomNode} A DOM element holding the parsed template data.
+     * @return {Element} A DOM element holding the parsed template data.
      */
     get : function(id, view, partials) {
+      // get the content stored in the DOM
       var template = document.getElementById(id);
-      var inner = template.innerHTML;
+      return this.renderToNode(template.innerHTML, view, partials);
+    },
 
-      inner = this.toHtml(inner, view, partials);
+    /**
+     * Accepts a parsed template and returns a (potentially nested) node.
+     *
+     * @param template {String} The String containing the template.
+     * @return {Element} A DOM element holding the parsed template data.
+     */
+    _createNodeFromTemplate : function(template) {
+      // template is text only (no html elems) so use text node
+      if (template.search(/<|>/) === -1) {
+        return document.createTextNode(template);
+      }
+
+      // template has html elems so convert string into DOM nodes
+      var helper = qx.dom.Element.create("div");
+      helper.innerHTML = template;
 
-      var helper = qx.bom.Element.create("div");
-      helper.innerHTML = inner;
-      
       return helper.children[0];
     }
   }
 });
 
 (function() {
+// prevent using CommonJS exports object,
+// by shadowing global exports object
+var exports;
+
+// prevent using AMD compatible loader,
+// by shadowing global define function
+var define;
 
 /**
- * Below is the original mustache.js code. Snapshot date is mentioned in 
+ * Below is the original mustache.js code. Snapshot date is mentioned in
  * the head of this file.
+ * @ignore(exports)
+ * @ignore(define.*)
+ * @ignore(module.*)
+ * @lint ignoreNoLoopBlock()
  */
- 
\ No newline at end of file
diff --git a/wrappers/qooxdoo/qooxdoo.mustache.js.tpl.post b/wrappers/qooxdoo/qooxdoo.mustache.js.tpl.post
deleted file mode 100644
index e66f9e6..0000000
--- a/wrappers/qooxdoo/qooxdoo.mustache.js.tpl.post
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Above is the original mustache code.
- */
-
-// EXPOSE qooxdoo variant
-qx.bom.Template.version = Mustache.version;
-qx.bom.Template.toHtml = Mustache.to_html;
-
-})();
diff --git a/wrappers/requirejs/requirejs.mustache.js.tpl.post b/wrappers/requirejs/requirejs.mustache.js.tpl.post
deleted file mode 100644
index 632fd2a..0000000
--- a/wrappers/requirejs/requirejs.mustache.js.tpl.post
+++ /dev/null
@@ -1,3 +0,0 @@
-
-return Mustache;
-});
\ No newline at end of file
diff --git a/wrappers/requirejs/requirejs.mustache.js.tpl.pre b/wrappers/requirejs/requirejs.mustache.js.tpl.pre
deleted file mode 100644
index 160286d..0000000
--- a/wrappers/requirejs/requirejs.mustache.js.tpl.pre
+++ /dev/null
@@ -1,6 +0,0 @@
-/*
-Shameless port of a shameless port ^ 2
- at defunkt => @janl => @aq => @voodootikigod => @timruffles
- 
-*/
-define(function(){
diff --git a/wrappers/yui3/mustache.js.post b/wrappers/yui3/mustache.js.post
new file mode 100644
index 0000000..3decbf8
--- /dev/null
+++ b/wrappers/yui3/mustache.js.post
@@ -0,0 +1,4 @@
+
+    Y.mustache = Mustache.render;
+
+}, "0");
diff --git a/wrappers/yui3/mustache.js.tpl.pre b/wrappers/yui3/mustache.js.pre
similarity index 100%
rename from wrappers/yui3/mustache.js.tpl.pre
rename to wrappers/yui3/mustache.js.pre
diff --git a/wrappers/yui3/mustache.js.tpl.post b/wrappers/yui3/mustache.js.tpl.post
deleted file mode 100644
index 373d827..0000000
--- a/wrappers/yui3/mustache.js.tpl.post
+++ /dev/null
@@ -1,4 +0,0 @@
-
-    Y.mustache = Mustache.to_html;
-
-}, "0");

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/collab-maint/mustache.js.git



More information about the Pkg-javascript-commits mailing list