| @@ -1,5 +1,6 @@ | |||||
| .DS_Store | .DS_Store | ||||
| .rvmrc | .rvmrc | ||||
| node_modules | |||||
| runner.js | runner.js | ||||
| jquery.mustache.js | jquery.mustache.js | ||||
| qooxdoo.mustache.js | qooxdoo.mustache.js | ||||
| @@ -0,0 +1,5 @@ | |||||
| { | |||||
| "eqnull": true, | |||||
| "evil": true | |||||
| } | |||||
| @@ -1,5 +1,4 @@ | |||||
| rvm: | |||||
| - 1.9.2 | |||||
| before_script: | |||||
| - sudo apt-get -y install xulrunner-2.0 | |||||
| - gem install rspec | |||||
| language: node_js | |||||
| node_js: | |||||
| - 0.6 | |||||
| @@ -0,0 +1,27 @@ | |||||
| = HEAD / 22 Sep 2012 | |||||
| * 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). | |||||
| @@ -3,21 +3,8 @@ The MIT License | |||||
| Copyright (c) 2009 Chris Wanstrath (Ruby) | Copyright (c) 2009 Chris Wanstrath (Ruby) | ||||
| Copyright (c) 2010 Jan Lehnardt (JavaScript) | Copyright (c) 2010 Jan Lehnardt (JavaScript) | ||||
| 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. | |||||
| 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. | |||||
| @@ -2,31 +2,23 @@ | |||||
| > What could be more logical awesome than no logic at all? | > 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/) template system in JavaScript. | |||||
| [mustache.js](http://github.com/janl/mustache.js) is an implementation of the [mustache](http://mustache.github.com/) template system in JavaScript. | |||||
| [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](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. | |||||
| 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. | |||||
| 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). | |||||
| 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? | ## 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. | |||||
| ## Who uses mustache.js? | ## 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! | |||||
| ## Usage | ## Usage | ||||
| @@ -41,36 +33,26 @@ Below is quick example how to use mustache.js: | |||||
| var output = Mustache.render("{{title}} spends {{calc}}", view); | var output = Mustache.render("{{title}} spends {{calc}}", view); | ||||
| 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. | |||||
| ### CommonJS | |||||
| mustache.js is usable without any modification in both browsers and [CommonJS](http://www.commonjs.org/) | |||||
| environments like [node.js](http://nodejs.org/). To use it as a CommonJS module, | |||||
| simply require the file, like this: | |||||
| var Mustache = require("mustache"); | |||||
| 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. | |||||
| ## Templates | ## Templates | ||||
| 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. | |||||
| 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. | There are several types of tags available in mustache.js. | ||||
| ### Variables | ### 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. | |||||
| 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. | |||||
| 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. | |||||
| View: | |||||
| 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. | |||||
| { | |||||
| "name": "Chris", | |||||
| "company": "<b>GitHub</b>" | |||||
| } | |||||
| Template: | Template: | ||||
| @@ -80,13 +62,6 @@ Template: | |||||
| * {{{company}}} | * {{{company}}} | ||||
| * {{&company}} | * {{&company}} | ||||
| View: | |||||
| { | |||||
| "name": "Chris", | |||||
| "company": "<b>GitHub</b>" | |||||
| } | |||||
| Output: | Output: | ||||
| * Chris | * Chris | ||||
| @@ -95,13 +70,7 @@ Output: | |||||
| * <b>GitHub</b> | * <b>GitHub</b> | ||||
| * <b>GitHub</b> | * <b>GitHub</b> | ||||
| JavaScript's dot notation may be used to access keys that are properties of | |||||
| objects in a view. | |||||
| Template: | |||||
| * {{name.first}} {{name.last}} | |||||
| * {{age}} | |||||
| JavaScript's dot notation may be used to access keys that are properties of objects in a view. | |||||
| View: | View: | ||||
| @@ -113,6 +82,11 @@ View: | |||||
| "age": "RIP" | "age": "RIP" | ||||
| } | } | ||||
| Template: | |||||
| * {{name.first}} {{name.last}} | |||||
| * {{age}} | |||||
| Output: | Output: | ||||
| * Michael Jackson | * Michael Jackson | ||||
| @@ -120,19 +94,21 @@ Output: | |||||
| ### Sections | ### Sections | ||||
| Sections render blocks of text one or more times, depending on the value of the | |||||
| key in the current context. | |||||
| 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". | |||||
| 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. | The behavior of the section is determined by the value of the key. | ||||
| #### False Values or Empty Lists | #### False Values or Empty Lists | ||||
| If the `person` key exists and has a value of `null`, `undefined`, or `false`, | |||||
| or is an empty list, the block will not be rendered. | |||||
| If the `person` key does not exist, or exists and has a value of `null`, `undefined`, or `false`, or is an empty list, the block will not be rendered. | |||||
| View: | |||||
| { | |||||
| "person": false | |||||
| } | |||||
| Template: | Template: | ||||
| @@ -141,30 +117,15 @@ Template: | |||||
| Never shown! | Never shown! | ||||
| {{/person}} | {{/person}} | ||||
| View: | |||||
| { | |||||
| "person": true | |||||
| } | |||||
| Output: | Output: | ||||
| Shown. | Shown. | ||||
| #### Non-Empty Lists | #### 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. | |||||
| Template: | |||||
| 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. | |||||
| {{#stooges}} | |||||
| <b>{{name}}</b> | |||||
| {{/stooges}} | |||||
| 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: | View: | ||||
| @@ -176,20 +137,19 @@ View: | |||||
| ] | ] | ||||
| } | } | ||||
| Template: | |||||
| {{#stooges}} | |||||
| <b>{{name}}</b> | |||||
| {{/stooges}} | |||||
| Output: | Output: | ||||
| <b>Moe</b> | <b>Moe</b> | ||||
| <b>Larry</b> | <b>Larry</b> | ||||
| <b>Curly</b> | <b>Curly</b> | ||||
| When looping over an array of strings, a `.` can be used to refer to the current | |||||
| item in the list. | |||||
| Template: | |||||
| {{#musketeers}} | |||||
| * {{.}} | |||||
| {{/musketeers}} | |||||
| When looping over an array of strings, a `.` can be used to refer to the current item in the list. | |||||
| View: | View: | ||||
| @@ -197,6 +157,12 @@ View: | |||||
| "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"] | "musketeers": ["Athos", "Aramis", "Porthos", "D'Artagnan"] | ||||
| } | } | ||||
| Template: | |||||
| {{#musketeers}} | |||||
| * {{.}} | |||||
| {{/musketeers}} | |||||
| Output: | Output: | ||||
| * Athos | * Athos | ||||
| @@ -204,14 +170,7 @@ Output: | |||||
| * Porthos | * Porthos | ||||
| * D'Artagnan | * D'Artagnan | ||||
| 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. | |||||
| Template: | |||||
| {{#beatles}} | |||||
| * {{name}} | |||||
| {{/beatles}} | |||||
| 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: | View: | ||||
| @@ -227,6 +186,12 @@ View: | |||||
| } | } | ||||
| } | } | ||||
| Template: | |||||
| {{#beatles}} | |||||
| * {{name}} | |||||
| {{/beatles}} | |||||
| Output: | Output: | ||||
| * John Lennon | * John Lennon | ||||
| @@ -236,14 +201,7 @@ Output: | |||||
| #### Functions | #### 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. | |||||
| Template: | |||||
| {{#bold}}Hi {{name}}.{{/bold}} | |||||
| 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: | View: | ||||
| @@ -256,20 +214,17 @@ View: | |||||
| } | } | ||||
| } | } | ||||
| Template: | |||||
| {{#bold}}Hi {{name}}.{{/bold}} | |||||
| Output: | Output: | ||||
| <b>Hi Tater.</b> | <b>Hi Tater.</b> | ||||
| ### Inverted Sections | ### Inverted Sections | ||||
| 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`, or an empty list. | |||||
| Template: | |||||
| {{#repos}}<b>{{name}}</b>{{/repos}} | |||||
| {{^repos}}No repos :({{/repos}} | |||||
| 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`, or an empty list. | |||||
| View: | View: | ||||
| @@ -277,6 +232,11 @@ View: | |||||
| "repos": [] | "repos": [] | ||||
| } | } | ||||
| Template: | |||||
| {{#repos}}<b>{{name}}</b>{{/repos}} | |||||
| {{^repos}}No repos :({{/repos}} | |||||
| Output: | Output: | ||||
| No repos :( | No repos :( | ||||
| @@ -297,8 +257,7 @@ Comments may contain newlines. | |||||
| Partials begin with a greater than sign, like {{> box}}. | Partials begin with a greater than sign, like {{> box}}. | ||||
| Partials are rendered at runtime (as opposed to compile time), so recursive | |||||
| partials are possible. Just avoid infinite loops. | |||||
| Partials are rendered at runtime (as opposed to compile time), so recursive partials are possible. Just avoid infinite loops. | |||||
| They also inherit the calling context. Whereas in ERB you may have this: | They also inherit the calling context. Whereas in ERB you may have this: | ||||
| @@ -308,9 +267,7 @@ Mustache requires only this: | |||||
| {{> next_more}} | {{> next_more}} | ||||
| 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, or template expansion, even though it's not literally true. | |||||
| 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, or template expansion, even though it's not literally true. | |||||
| For example, this template and partial: | For example, this template and partial: | ||||
| @@ -330,14 +287,11 @@ Can be thought of as a single, expanded template: | |||||
| <strong>{{name}}</strong> | <strong>{{name}}</strong> | ||||
| {{/names}} | {{/names}} | ||||
| 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. | |||||
| 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. | |||||
| ### Set Delimiter | ### Set Delimiter | ||||
| Set Delimiter tags start with an equals sign and change the tag delimiters from | |||||
| `{{` and `}}` to custom strings. | |||||
| Set Delimiter tags start with an equals sign and change the tag delimiters from `{{` and `}}` to custom strings. | |||||
| Consider the following contrived example: | Consider the following contrived example: | ||||
| @@ -347,55 +301,57 @@ Consider the following contrived example: | |||||
| <%={{ }}=%> | <%={{ }}=%> | ||||
| * {{ default_tags_again }} | * {{ 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. | |||||
| 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](http://google-ctemplate.googlecode.com/svn/trunk/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." | |||||
| According to [ctemplates](http://google-ctemplate.googlecode.com/svn/trunk/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. | Custom delimiters may not contain whitespace or the equals sign. | ||||
| ## Streaming | |||||
| To stream template results out of mustache.js, you can pass an optional callback | |||||
| to the call to `Mustache.render`: | |||||
| Mustache.render(template, view, partials, function (chunk) { | |||||
| print(chunk); | |||||
| }); | |||||
| When the template is finished rendering, the callback will be called with `null` | |||||
| after which it won't be called anymore for that rendering. | |||||
| ## Plugins for JavaScript Libraries | ## Plugins for JavaScript Libraries | ||||
| By default mustache.js may be used in a browser or any [CommonJS](http://www.commonjs.org/) | |||||
| environment, including [node](http://nodejs.org/). Additionally, 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: | |||||
| - [jQuery](http://jquery.com/) | - [jQuery](http://jquery.com/) | ||||
| - [MooTools](http://mootools.net/) | - [MooTools](http://mootools.net/) | ||||
| - [Dojo](http://www.dojotoolkit.org/) | - [Dojo](http://www.dojotoolkit.org/) | ||||
| - [YUI](http://developer.yahoo.com/yui/) | - [YUI](http://developer.yahoo.com/yui/) | ||||
| - [RequireJS](http://requirejs.org/) | |||||
| - [qooxdoo](http://qooxdoo.org/) | - [qooxdoo](http://qooxdoo.org/) | ||||
| These may be built using [Rake](http://rake.rubyforge.org/) and one of the | |||||
| following commands: | |||||
| These may be built using [Rake](http://rake.rubyforge.org/) and one of the following commands: | |||||
| $ rake jquery | $ rake jquery | ||||
| $ rake mootools | $ rake mootools | ||||
| $ rake dojo | $ rake dojo | ||||
| $ rake yui | $ rake yui | ||||
| $ rake requirejs | |||||
| $ rake qooxdoo | $ rake qooxdoo | ||||
| ## Testing | |||||
| The mustache.js test suite uses the [vows](http://vowsjs.org/) testing framework. In order to run the tests you'll need to install [node](http://nodejs.org/). Once that's done you can install vows using [npm](http://npmjs.org/). | |||||
| $ npm install -g vows | |||||
| Then run the tests. | |||||
| $ vows --spec | |||||
| 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: | |||||
| $ TEST=mytest vows test/render_test.js | |||||
| ## Thanks | ## 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 | * Chris Wanstrath / defunkt | ||||
| * Alexander Lang / langalex | * Alexander Lang / langalex | ||||
| @@ -1,15 +1,33 @@ | |||||
| require 'rake' | require 'rake' | ||||
| require 'rake/clean' | 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 | |||||
| ROOT = File.expand_path('..', __FILE__) | |||||
| MUSTACHE_JS = File.read(File.join(ROOT, 'mustache.js')) | |||||
| def mustache_version | |||||
| match = MUSTACHE_JS.match(/exports\.version = "([^"]+)";/) | |||||
| match[1] | |||||
| end | |||||
| def minified_file | |||||
| ENV['FILE'] || 'mustache.min.js' | |||||
| end | |||||
| desc "Run all tests, requires vows (see http://vowsjs.org)" | |||||
| task :test do | |||||
| sh "vows --spec" | |||||
| end | |||||
| desc "Minify to #{minified_file}, requires UglifyJS (see http://marijnhaverbeke.nl/uglifyjs)" | |||||
| task :minify do | |||||
| sh "uglifyjs mustache.js > #{minified_file}" | |||||
| end | |||||
| desc "Run JSHint, requires jshint (see http://www.jshint.com)" | |||||
| task :lint do | |||||
| sh "jshint mustache.js" | |||||
| end | end | ||||
| # Creates a task that uses the various template wrappers to make a wrapped | # Creates a task that uses the various template wrappers to make a wrapped | ||||
| @@ -47,13 +65,4 @@ templated_build "jQuery" | |||||
| templated_build "MooTools" | templated_build "MooTools" | ||||
| templated_build "Dojo", :location => "dojox/string" | templated_build "Dojo", :location => "dojox/string" | ||||
| templated_build "YUI3", :location => "yui3/mustache" | templated_build "YUI3", :location => "yui3/mustache" | ||||
| templated_build "RequireJS" | |||||
| templated_build "qooxdoo" | templated_build "qooxdoo" | ||||
| task :minify do | |||||
| # npm install uglify-js | |||||
| mmjs = "mustache.min.js" | |||||
| `echo "/*! Version: 0.5.1-dev */" > #{mmjs}` | |||||
| `uglifyjs mustache.js >> #{mmjs}` | |||||
| puts "Created #{mmjs}" | |||||
| end | |||||
| @@ -1,62 +0,0 @@ | |||||
| ## Running the mustache.js test suite | |||||
| 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 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 called `somename.mustache` | |||||
| * Create a JavaScript file containing the view called `somename.js` | |||||
| * Create a text file with the expected result called `somename.txt` | |||||
| @@ -2,7 +2,7 @@ | |||||
| <package > | <package > | ||||
| <metadata> | <metadata> | ||||
| <id>mustache.js</id> | <id>mustache.js</id> | ||||
| <version>0.5.0-dev</version> | |||||
| <version>0.7.0</version> | |||||
| <authors>mustache.js Authors</authors> | <authors>mustache.js Authors</authors> | ||||
| <licenseUrl>https://github.com/janl/mustache.js/blob/master/LICENSE</licenseUrl> | <licenseUrl>https://github.com/janl/mustache.js/blob/master/LICENSE</licenseUrl> | ||||
| <projectUrl>http://mustache.github.com/</projectUrl> | <projectUrl>http://mustache.github.com/</projectUrl> | ||||
| @@ -1,8 +1,17 @@ | |||||
| { | { | ||||
| "name": "mustache", | "name": "mustache", | ||||
| "version": "0.5.0-dev", | |||||
| "version": "0.7.0", | |||||
| "description": "Logic-less {{mustache}} templates with JavaScript", | "description": "Logic-less {{mustache}} templates with JavaScript", | ||||
| "author": "mustache.js Authors <http://github.com/janl/mustache.js>", | "author": "mustache.js Authors <http://github.com/janl/mustache.js>", | ||||
| "keywords": ["mustache", "template", "templates", "ejs"], | "keywords": ["mustache", "template", "templates", "ejs"], | ||||
| "main": "./mustache" | |||||
| "main": "./mustache.js", | |||||
| "devDependencies": { | |||||
| "vows": "0.6.x" | |||||
| }, | |||||
| "volo": { | |||||
| "url": "https://raw.github.com/janl/mustache.js/0.7.0/mustache.js" | |||||
| }, | |||||
| "scripts": { | |||||
| "test": "vows --spec" | |||||
| } | |||||
| } | } | ||||
| @@ -1,3 +0,0 @@ | |||||
| var ampersand_escape = { | |||||
| message: "Some <code>" | |||||
| }; | |||||
| @@ -1 +0,0 @@ | |||||
| var apostrophe = {'apos': "'", 'control':'X'}; | |||||
| @@ -1 +0,0 @@ | |||||
| var array_of_strings = {array_of_strings: ['hello', 'world']}; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var backslashes = { | |||||
| value: "\\abc" | |||||
| }; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var bug_11_eating_whitespace = { | |||||
| tag: "yo" | |||||
| }; | |||||
| @@ -1,4 +0,0 @@ | |||||
| var changing_delimiters = { | |||||
| "foo": "foooooooooooooo", | |||||
| "bar":"<b>bar!</b>" | |||||
| }; | |||||
| @@ -1,5 +0,0 @@ | |||||
| var comments = { | |||||
| title: function() { | |||||
| return "A Comedy of Errors"; | |||||
| } | |||||
| }; | |||||
| @@ -1,4 +0,0 @@ | |||||
| var disappearing_whitespace = { | |||||
| bedrooms: true, | |||||
| total: 1 | |||||
| }; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var empty_list = { | |||||
| jobs: [] | |||||
| }; | |||||
| @@ -1 +0,0 @@ | |||||
| var empty_sections = {}; | |||||
| @@ -1 +0,0 @@ | |||||
| var empty_template = {}; | |||||
| @@ -1 +0,0 @@ | |||||
| var error_not_found = {bar: 2}; | |||||
| @@ -1,6 +0,0 @@ | |||||
| var escaped = { | |||||
| title: function() { | |||||
| return "Bear > Shark"; | |||||
| }, | |||||
| entities: """ | |||||
| }; | |||||
| @@ -1,2 +0,0 @@ | |||||
| <h1>{{title}}</h1> | |||||
| But not {{entities}}. | |||||
| @@ -1,2 +0,0 @@ | |||||
| <h1>Bear > Shark</h1> | |||||
| But not ". | |||||
| @@ -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; | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -1 +0,0 @@ | |||||
| <b>Hi Tater.</b> To tinker? | |||||
| @@ -1,3 +0,0 @@ | |||||
| var inverted_section = { | |||||
| "repos": [] | |||||
| }; | |||||
| @@ -1 +0,0 @@ | |||||
| var multiline_comment = {}; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var partial_array_of_partials = { | |||||
| numbers: [{i: '1'}, {i: '2'}, {i: '3'}, {i: '4'}] | |||||
| }; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var partial_array_of_partials_implicit = { | |||||
| numbers: ['1', '2', '3', '4'] | |||||
| }; | |||||
| @@ -1,3 +0,0 @@ | |||||
| var partial_empty = { | |||||
| foo: 1 | |||||
| }; | |||||
| @@ -1,11 +0,0 @@ | |||||
| var partial_recursion = { | |||||
| name: '1', | |||||
| kids: [ | |||||
| { | |||||
| name: '1.1', | |||||
| children: [ | |||||
| {name: '1.1.1'} | |||||
| ] | |||||
| } | |||||
| ] | |||||
| }; | |||||
| @@ -1,4 +0,0 @@ | |||||
| {{name}} | |||||
| {{#kids}} | |||||
| {{>partial}} | |||||
| {{/kids}} | |||||
| @@ -1,4 +0,0 @@ | |||||
| {{name}} | |||||
| {{#children}} | |||||
| {{>partial}} | |||||
| {{/children}} | |||||
| @@ -1,3 +0,0 @@ | |||||
| 1 | |||||
| 1.1 | |||||
| 1.1.1 | |||||
| @@ -1,6 +0,0 @@ | |||||
| var partial_template = { | |||||
| title: function() { | |||||
| return "Welcome"; | |||||
| }, | |||||
| again: "Goodbye" | |||||
| }; | |||||
| @@ -1,4 +0,0 @@ | |||||
| var string_as_context = { | |||||
| a_string: 'aa', | |||||
| a_list: ['a','b','c'] | |||||
| }; | |||||
| @@ -1 +0,0 @@ | |||||
| var two_sections = {}; | |||||
| @@ -1,5 +0,0 @@ | |||||
| var unescaped = { | |||||
| title: function() { | |||||
| return "Bear > Shark"; | |||||
| } | |||||
| }; | |||||
| @@ -1,218 +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 | |||||
| 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) | |||||
| template = File.read(File.join(FILES, "#{name}.mustache")) | |||||
| view = File.read(File.join(FILES, "#{name}.js")) | |||||
| partial_file = File.join(FILES, "#{name}.partial") | |||||
| partial = if File.exist?(partial_file) | |||||
| File.read(partial_file) | |||||
| end | |||||
| expect = File.read(File.join(FILES, "#{name}.txt")) | |||||
| [template, view, partial, expect] | |||||
| end | |||||
| def run_js(runner, js) | |||||
| cmd = case runner | |||||
| when :spidermonkey | |||||
| JS_PATH | |||||
| when :jsc | |||||
| JSC_PATH | |||||
| when :rhino | |||||
| "java #{RHINO_JAR}" | |||||
| when :v8 | |||||
| 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 result when invoked multiple times" do | |||||
| js = <<-JS | |||||
| #{@boilerplate} | |||||
| Mustache.render("x") | |||||
| print(Mustache.render("x")); | |||||
| JS | |||||
| run_js(@runner, js).should == "x\n" | |||||
| end | |||||
| it "should clear the context after each run" do | |||||
| js = <<-JS | |||||
| #{@boilerplate} | |||||
| Mustache.render("{{#list}}{{x}}{{/list}}", {list: [{x: 1}]}) | |||||
| try { | |||||
| print(Mustache.render("{{#list}}{{x}}{{/list}}", {list: [{}]})); | |||||
| } catch(e) { | |||||
| print('ERROR: ' + e.message); | |||||
| } | |||||
| JS | |||||
| run_js(@runner, js).should == "\n" | |||||
| end | |||||
| TESTS.each do |test| | |||||
| describe test do | |||||
| it "should render the correct output" do | |||||
| template, view, partial, expect = load_test(test) | |||||
| js = <<-JS | |||||
| try { | |||||
| #{@boilerplate} | |||||
| var template = #{template.to_json}; | |||||
| #{view} | |||||
| var partials = {partial: #{partial ? partial.to_json : '""'}}; | |||||
| print(Mustache.render(template, #{test}, partials)); | |||||
| } catch(e) { | |||||
| print('ERROR: ' + e.message); | |||||
| } | |||||
| JS | |||||
| run_js(@runner, js).chomp.should == expect | |||||
| end | |||||
| # it "should send the correct output" do | |||||
| # template, view, partial, expect = load_test(test) | |||||
| # | |||||
| # js = <<-JS | |||||
| # try { | |||||
| # #{@boilerplate} | |||||
| # var template = #{template.to_json}; | |||||
| # #{view} | |||||
| # var partials = { | |||||
| # "partial": #{(partial || '').to_json} | |||||
| # }; | |||||
| # var buffer = []; | |||||
| # var send = function (chunk) { | |||||
| # buffer.push(chunk); | |||||
| # }; | |||||
| # Mustache.render(template, #{test}, partials, send); | |||||
| # print(buffer.join("")); | |||||
| # } catch(e) { | |||||
| # print('ERROR: ' + e.message); | |||||
| # } | |||||
| # JS | |||||
| # | |||||
| # run_js(@runner, js).chomp.should == expect | |||||
| # end | |||||
| end | |||||
| end | |||||
| end | |||||
| context "running in V8 (Chrome, node)" do | |||||
| if File.exist?(NODE_PATH) | |||||
| before(:all) do | |||||
| $stdout.write "Testing in V8 " | |||||
| @runner = :v8 | |||||
| @boilerplate = MUSTACHE.dup | |||||
| @boilerplate << <<-JS | |||||
| var print = console.log; | |||||
| JS | |||||
| end | |||||
| after(:all) do | |||||
| puts " Done!" | |||||
| end | |||||
| it_should_behave_like "mustache rendering" | |||||
| else | |||||
| puts "Skipping tests in V8 (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 the tests in at least one engine ... " | |||||
| end | |||||
| after(:each) do | |||||
| puts @exception.nil? ? "OK" : "ERROR" | |||||
| end | |||||
| it "should have run at least one time" do | |||||
| $engines_run.should > 0 | |||||
| end | |||||
| end | |||||
| end | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| message: "Some <code>" | |||||
| }) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ({ | |||||
| 'apos': "'", | |||||
| 'control': 'X' | |||||
| }) | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| array_of_strings: ['hello', 'world'] | |||||
| }) | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| value: "\\abc" | |||||
| }) | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| tag: "yo" | |||||
| }) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ({ | |||||
| "foo": "foooooooooooooo", | |||||
| "bar": "<b>bar!</b>" | |||||
| }) | |||||
| @@ -0,0 +1,5 @@ | |||||
| ({ | |||||
| title: function () { | |||||
| return "A Comedy of Errors"; | |||||
| } | |||||
| }) | |||||
| @@ -1,5 +1,5 @@ | |||||
| var complex = { | |||||
| header: function() { | |||||
| ({ | |||||
| header: function () { | |||||
| return "Colors"; | return "Colors"; | ||||
| }, | }, | ||||
| item: [ | item: [ | ||||
| @@ -7,13 +7,13 @@ var complex = { | |||||
| {name: "green", current: false, url: "#Green"}, | {name: "green", current: false, url: "#Green"}, | ||||
| {name: "blue", current: false, url: "#Blue"} | {name: "blue", current: false, url: "#Blue"} | ||||
| ], | ], | ||||
| link: function() { | |||||
| link: function () { | |||||
| return this["current"] !== true; | return this["current"] !== true; | ||||
| }, | }, | ||||
| list: function() { | |||||
| list: function () { | |||||
| return this.item.length !== 0; | return this.item.length !== 0; | ||||
| }, | }, | ||||
| empty: function() { | |||||
| empty: function () { | |||||
| return this.item.length === 0; | return this.item.length === 0; | ||||
| } | } | ||||
| }; | |||||
| }) | |||||
| @@ -1,8 +1,8 @@ | |||||
| var context_lookup = { | |||||
| ({ | |||||
| "outer": { | "outer": { | ||||
| "id": 1, | "id": 1, | ||||
| "second": { | "second": { | ||||
| "nothing": 2 | "nothing": 2 | ||||
| } | } | ||||
| } | } | ||||
| }; | |||||
| }) | |||||
| @@ -1,6 +1,6 @@ | |||||
| var delimiters = { | |||||
| ({ | |||||
| first: "It worked the first time.", | first: "It worked the first time.", | ||||
| second: "And it worked the second time.", | second: "And it worked the second time.", | ||||
| third: "Then, surprisingly, it worked the third time.", | third: "Then, surprisingly, it worked the third time.", | ||||
| fourth: "Fourth time also fine!." | fourth: "Fourth time also fine!." | ||||
| } | |||||
| }) | |||||
| @@ -0,0 +1,4 @@ | |||||
| ({ | |||||
| bedrooms: true, | |||||
| total: 1 | |||||
| }) | |||||
| @@ -1,17 +1,17 @@ | |||||
| var dot_notation = { | |||||
| ({ | |||||
| name: "A Book", | name: "A Book", | ||||
| authors: ["John Power", "Jamie Walsh"], | authors: ["John Power", "Jamie Walsh"], | ||||
| price:{ | |||||
| price: { | |||||
| value: 200, | value: 200, | ||||
| vat: function() { | |||||
| vat: function () { | |||||
| return this.value * 0.2; | return this.value * 0.2; | ||||
| }, | }, | ||||
| currency: { | currency: { | ||||
| symbol: '€', | |||||
| name: 'Euro' | |||||
| symbol: '$', | |||||
| name: 'USD' | |||||
| } | } | ||||
| }, | }, | ||||
| availability:{ | |||||
| availability: { | |||||
| status: true, | status: true, | ||||
| text: "In Stock" | text: "In Stock" | ||||
| }, | }, | ||||
| @@ -20,4 +20,4 @@ var dot_notation = { | |||||
| zero: 0, | zero: 0, | ||||
| notTrue: false | notTrue: false | ||||
| } | } | ||||
| }; | |||||
| }) | |||||
| @@ -1,8 +1,8 @@ | |||||
| <!-- exciting part --> | <!-- exciting part --> | ||||
| <h1>{{name}}</h1> | <h1>{{name}}</h1> | ||||
| <p>Authors: <ul>{{#authors}}<li>{{.}}</li>{{/authors}}</ul></p> | <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 --> | <!-- boring part --> | ||||
| <h2>Test truthy false values:</h2> | <h2>Test truthy false values:</h2> | ||||
| <p>Zero: {{truthy.zero}}</p> | <p>Zero: {{truthy.zero}}</p> | ||||
| @@ -1,8 +1,8 @@ | |||||
| <!-- exciting part --> | <!-- exciting part --> | ||||
| <h1>A Book</h1> | <h1>A Book</h1> | ||||
| <p>Authors: <ul><li>John Power</li><li>Jamie Walsh</li></ul></p> | <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 --> | <!-- boring part --> | ||||
| <h2>Test truthy false values:</h2> | <h2>Test truthy false values:</h2> | ||||
| <p>Zero: 0</p> | <p>Zero: 0</p> | ||||
| @@ -1,5 +1,5 @@ | |||||
| var double_render = { | |||||
| ({ | |||||
| foo: true, | foo: true, | ||||
| bar: "{{win}}", | bar: "{{win}}", | ||||
| win: "FAIL" | win: "FAIL" | ||||
| }; | |||||
| }) | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| jobs: [] | |||||
| }) | |||||
| @@ -0,0 +1 @@ | |||||
| ({}) | |||||
| @@ -1,6 +1,6 @@ | |||||
| var empty_string = { | |||||
| ({ | |||||
| description: "That is all!", | description: "That is all!", | ||||
| child: { | child: { | ||||
| description: "" | description: "" | ||||
| } | } | ||||
| }; | |||||
| }) | |||||
| @@ -0,0 +1 @@ | |||||
| ({}) | |||||
| @@ -0,0 +1,3 @@ | |||||
| ({ | |||||
| bar: 2 | |||||
| }) | |||||
| @@ -0,0 +1,6 @@ | |||||
| ({ | |||||
| title: function () { | |||||
| return "Bear > Shark"; | |||||
| }, | |||||
| entities: "" \"'<>/" | |||||
| }) | |||||
| @@ -0,0 +1,2 @@ | |||||
| <h1>{{title}}</h1> | |||||
| And even {{entities}}, but not {{{entities}}}. | |||||
| @@ -0,0 +1,2 @@ | |||||
| <h1>Bear > Shark</h1> | |||||
| And even &quot; "'<>/, but not " "'<>/. | |||||
| @@ -0,0 +1,8 @@ | |||||
| ({ | |||||
| "emptyString": "", | |||||
| "emptyArray": [], | |||||
| "zero": 0, | |||||
| "null": null, | |||||
| "undefined": undefined, | |||||
| "NaN": 0/0 | |||||
| }) | |||||