From aa5765971aa7c58cb23b16924de97a517afb3730 Mon Sep 17 00:00:00 2001 From: djchie Date: Thu, 17 Sep 2015 20:36:35 -0700 Subject: [PATCH 001/172] Fix spelling error to "aforementioned" --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 596b59b10..ecb5ce54f 100644 --- a/README.md +++ b/README.md @@ -496,7 +496,7 @@ $ npm install mustache --save-dev $ npm run build ``` -The command line tool is basically a wrapper around `Mustache.render` so you get all the aformentioned features. +The command line tool is basically a wrapper around `Mustache.render` so you get all the aforementioned features. ## Testing From d1019d298cef23dc50451f20b6bc6b22d21d1303 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Fri, 18 Sep 2015 08:56:56 +0200 Subject: [PATCH 002/172] npm 2.x and node v4 on Travis Use latest v2 release of npm as the just released v3 doesnt seem to be node v0.8 compliant atm. And test on node v4 for obvious reasons. --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index f86ffe2ef..241e84a83 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,8 +3,9 @@ node_js: - 0.8 - '0.10' - 0.12 + - 4 before_install: - - npm install -g npm + - npm install -g npm@2.x script: - npm test - "test $TRAVIS_PULL_REQUEST != 'false' || test $TRAVIS_NODE_VERSION != '0.12' || npm run test-browser" From 67fe0e5d59bda578ea08526bb58ef0f3db2d6132 Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Sat, 19 Sep 2015 17:01:58 +0200 Subject: [PATCH 003/172] chore: updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d812427aa..2b53324ee 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "^2.3.0", - "eslint": "^0.20.0", + "eslint": "1.5.0", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From 9d967ea61f09174238d7ff51116dfbc9339a0fbd Mon Sep 17 00:00:00 2001 From: Jan Lehnardt Date: Mon, 21 Sep 2015 11:18:30 +0200 Subject: [PATCH 004/172] chore: updated package.json --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 2b53324ee..bbe543a5d 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "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": "^2.3.0", + "chai": "3.3.0", "eslint": "1.5.0", "mocha": "^2.1.0", "zuul": "^2.1.1" From 847499ad678425bc766d9ecccbed4d34541e9f79 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Fri, 2 Oct 2015 19:23:15 +0200 Subject: [PATCH 005/172] chore(package): update eslint to version 1.6.0 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index bbe543a5d..d6df6a4ed 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "3.3.0", - "eslint": "1.5.0", + "eslint": "1.6.0", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From ac447ec05321a4d46156f000e3480a242434f230 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Wed, 7 Oct 2015 10:42:26 +0200 Subject: [PATCH 006/172] Remove IE8 from zuul test runs --- .zuul.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.zuul.yml b/.zuul.yml index b5703b1bf..b2efeea0e 100644 --- a/.zuul.yml +++ b/.zuul.yml @@ -5,4 +5,4 @@ browsers: - name: firefox version: latest - name: ie - version: 8..latest \ No newline at end of file + version: 9..latest \ No newline at end of file From a951348003a2fbd37e6890f9733af12634494a49 Mon Sep 17 00:00:00 2001 From: Mateus Ortiz Date: Tue, 6 Oct 2015 17:23:04 -0300 Subject: [PATCH 007/172] Add instructions install on top #493 fix local install Fix order section and grammatical Fix the comments Fix command line mustache --- README.md | 78 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 30 deletions(-) diff --git a/README.md b/README.md index ecb5ce54f..63b775a40 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,54 @@ 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. + ## 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! @@ -468,36 +516,6 @@ These may be built using [Rake](http://rake.rubyforge.org/) and one of the follo $ rake yui3 $ rake qooxdoo -## 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 -$ 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 aforementioned features. - ## Testing In order to run the tests you'll need to install [node](http://nodejs.org/). From d0cf9c65ee3e924b62b56030b16db7e391dc824a Mon Sep 17 00:00:00 2001 From: palkan Date: Wed, 14 Oct 2015 11:00:41 +0300 Subject: [PATCH 008/172] [Fix #483] Add partials support to cli --- README.md | 6 ++ bin/mustache | 31 +++++++-- test/_files/cli_with_partials.json | 14 ++++ test/_files/cli_with_partials.mustache | 7 ++ test/_files/cli_with_partials.txt | 2 + test/cli-test.js | 96 +++++++++++++++++--------- 6 files changed, 120 insertions(+), 36 deletions(-) create mode 100644 test/_files/cli_with_partials.json create mode 100644 test/_files/cli_with_partials.mustache create mode 100644 test/_files/cli_with_partials.txt diff --git a/README.md b/README.md index 63b775a40..2233ab983 100644 --- a/README.md +++ b/README.md @@ -70,6 +70,12 @@ $ 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! diff --git a/bin/mustache b/bin/mustache index a88c9b4f9..730e79aaf 100755 --- a/bin/mustache +++ b/bin/mustache @@ -1,9 +1,18 @@ #!/usr/bin/env node -var fs = require('fs'); +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]; @@ -17,7 +26,7 @@ if (!templateArg || !viewArg) { process.exit(1); } -run(readView, readTemplate, render, toStdout); +run(readPartials, readView, readTemplate, render, toStdout); /** * Runs a list of functions as a waterfall. @@ -63,13 +72,23 @@ function parseView(str) { } } +function readPartials(cb) { + if(!partialsPaths.length) return cb(); + var partialPath = partialsPaths.pop(); + var partial = fs.createReadStream(partialPath); + streamToStr(partial, function(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)); + cb(Mustache.render(templateStr, jsonView, partials)); } function toStdout(cb, str) { @@ -105,4 +124,8 @@ function hasVersionArg() { return ['--version', '-v'].some(function(opt) { return process.argv.indexOf(opt) > -1; }); -} \ No newline at end of file +} + +function getPartialName(filename) { + return path.basename(filename, '.mustache') +} diff --git a/test/_files/cli_with_partials.json b/test/_files/cli_with_partials.json new file mode 100644 index 000000000..c6af1c841 --- /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 000000000..9c168d841 --- /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 000000000..f582397ea --- /dev/null +++ b/test/_files/cli_with_partials.txt @@ -0,0 +1,2 @@ +Howdy LeBron, CLI roxHowdy LeBron 2, CLI rox +

A Comedy of Errors

diff --git a/test/cli-test.js b/test/cli-test.js index 52cd7deeb..dd3ec3031 100644 --- a/test/cli-test.js +++ b/test/cli-test.js @@ -4,6 +4,7 @@ var fs = require('fs'); var path = require('path'); 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; var exec = require('child_process').exec; @@ -12,15 +13,6 @@ describe('Mustache CLI', function () { var expectedOutput; - before(function(done) { - fs.readFile(cliTxt, function onFsEnd(err, data) { - if (err) return done(err); - - expectedOutput = data.toString(); - done(); - }); - }); - 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); @@ -49,36 +41,76 @@ describe('Mustache CLI', function () { }); }); - 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(); + describe("without partials", function(){ + before(function(done) { + fs.readFile(cliTxt, function onFsEnd(err, data) { + if (err) return done(err); + + expectedOutput = data.toString(); + 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 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 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.notEqual(stderr.indexOf('Could not find file: test/_files/non-existing-template.mustache'), -1); - 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 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.notEqual(stderr.indexOf('Could not find file: test/_files/non-existing-view.json'), -1); - 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.notEqual(stderr.indexOf('Could not find file: test/_files/non-existing-template.mustache'), -1); + 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.notEqual(stderr.indexOf('Could not find file: test/_files/non-existing-view.json'), -1); + 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(); + }); + }); + }) }); From cbcd788b0cf1438fc7bf70d720044813ccc2c12f Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Thu, 15 Oct 2015 10:40:21 +0200 Subject: [PATCH 009/172] Linting CLI tool. Also minor .eslintrc change to be able to use `process.exit()`, instead of having to `throw new Error()` to exit the process. --- .eslintrc | 1 + bin/mustache | 54 ++++++++++++++++++++++++++-------------------------- package.json | 2 +- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/.eslintrc b/.eslintrc index 6cdfd8fe5..06a836015 100644 --- a/.eslintrc +++ b/.eslintrc @@ -14,6 +14,7 @@ "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/bin/mustache b/bin/mustache index 730e79aaf..6067e0b4b 100755 --- a/bin/mustache +++ b/bin/mustache @@ -10,7 +10,7 @@ var partials = {}; var partialsPaths = []; var partialArgIndex = -1; -while((partialArgIndex = process.argv.indexOf("-p")) > -1){ +while ((partialArgIndex = process.argv.indexOf('-p')) > -1) { partialsPaths.push(process.argv.splice(partialArgIndex, 2)[1]); } @@ -34,75 +34,75 @@ run(readPartials, readView, readTemplate, render, toStdout); * 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*/) { +function run (/*args*/) { var values = []; var fns = Array.prototype.slice.call(arguments); - function invokeNextFn(val) { + function invokeNextFn (val) { values.unshift(val); - if (fns.length == 0) return; + if (fns.length === 0) return; invoke(fns.shift()); } - function invoke(fn) { + function invoke (fn) { fn.apply(null, [invokeNextFn].concat(values)); } invoke(fns.shift()); } -function readView(cb) { +function readView (cb) { var view = isStdin(viewArg) ? process.openStdin() : fs.createReadStream(viewArg); - streamToStr(view, function(str) { + streamToStr(view, function onDone (str) { cb(parseView(str)); }); } -function 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'+ + '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(); +function readPartials (cb) { + if (!partialsPaths.length) return cb(); var partialPath = partialsPaths.pop(); var partial = fs.createReadStream(partialPath); - streamToStr(partial, function(str) { + streamToStr(partial, function onDone (str) { partials[getPartialName(partialPath)] = str; readPartials(cb); }); } -function readTemplate(cb) { +function readTemplate (cb) { var template = fs.createReadStream(templateArg); streamToStr(template, cb); } -function render(cb, templateStr, jsonView) { +function render (cb, templateStr, jsonView) { cb(Mustache.render(templateStr, jsonView, partials)); } -function toStdout(cb, str) { +function toStdout (cb, str) { cb(process.stdout.write(str)); } -function streamToStr(stream, cb) { +function streamToStr (stream, cb) { var data = ''; - stream.on('data', function(chunk) { + stream.on('data', function onData (chunk) { data += chunk; - }).once('end', function() { + }).once('end', function onEnd () { cb(data.toString()); - }).on('error', function(err) { + }).on('error', function onError (err) { if (wasNotFound(err)) { console.error('Could not find file:', err.path); } else { @@ -112,20 +112,20 @@ function streamToStr(stream, cb) { }); } -function isStdin(viewArg) { - return viewArg === '-'; +function isStdin (view) { + return view === '-'; } -function wasNotFound(err) { +function wasNotFound (err) { return err.code && err.code === 'ENOENT'; } -function hasVersionArg() { - return ['--version', '-v'].some(function(opt) { +function hasVersionArg () { + return ['--version', '-v'].some(function matchInArgs (opt) { return process.argv.indexOf(opt) > -1; }); } -function getPartialName(filename) { - return path.basename(filename, '.mustache') +function getPartialName (filename) { + return path.basename(filename, '.mustache'); } diff --git a/package.json b/package.json index d6df6a4ed..9493850e8 100644 --- a/package.json +++ b/package.json @@ -32,7 +32,7 @@ "npm": ">=1.4.0" }, "scripts": { - "pretest": "eslint mustache.js", + "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", From aac23a542c6cb7cd17a8b995fdc0406486cd3a23 Mon Sep 17 00:00:00 2001 From: David da Silva Date: Thu, 15 Oct 2015 12:13:49 +0200 Subject: [PATCH 010/172] :ship: bump to version 2.2.0 --- CHANGELOG.md | 33 +++++++++++++++++++++++++++++++-- mustache.js | 2 +- mustache.js.nuspec | 2 +- mustache.min.js | 2 +- package.json | 2 +- 5 files changed, 35 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 39dcb74a5..d44371857 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,30 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [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 @@ -135,6 +159,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Fixed a bug that clashed with QUnit (thanks [@kannix]). * Added volo support (thanks [@guybedford]). +[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 @@ -163,12 +188,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). [#274]: https://github.com/janl/mustache.js/issues/274 [#466]: https://github.com/janl/mustache.js/issues/466 -[@Andersos]: https://github.com/Andersos -[@TiddoLangerak]: https://github.com/TiddoLangerak [@afc163]: https://github.com/afc163 +[@Andersos]: https://github.com/Andersos [@cmbuckley]: https://github.com/cmbuckley [@cweider]: https://github.com/cweider [@dasilvacontin]: https://github.com/dasilvacontin +[@djchie]: https://github.com/djchie [@fallenice]: https://github.com/fallenice [@guybedford]: https://github.com/guybedford [@jfmercer]: https://github.com/jfmercer @@ -176,9 +201,13 @@ This project adheres to [Semantic Versioning](http://semver.org/). [@kannix]: https://github.com/kannix [@kkirsche]: https://github.com/kkirsche [@kristijanmatic]: https://github.com/kristijanmatic +[@mateusortiz]: https://github.com/mateusortiz [@mikesherov]: https://github.com/mikesherov [@mjackson]: https://github.com/mjackson [@nagaozen]: https://github.com/nagaozen +[@palkan]: https://github.com/palkan [@pgilad]: https://github.com/pgilad [@phillipj]: https://github.com/phillipj +[@ShashankaNataraj]: https://github.com/ShashankaNataraj +[@TiddoLangerak]: https://github.com/TiddoLangerak [@yousefcisco]: https://github.com/yousefcisco diff --git a/mustache.js b/mustache.js index b3266f7d3..935e007d5 100644 --- a/mustache.js +++ b/mustache.js @@ -565,7 +565,7 @@ }; mustache.name = 'mustache.js'; - mustache.version = '2.1.3'; + mustache.version = '2.2.0'; mustache.tags = [ '{{', '}}' ]; // All high-level mustache.* functions use this writer. diff --git a/mustache.js.nuspec b/mustache.js.nuspec index c926dd1c6..5b8d6a258 100644 --- a/mustache.js.nuspec +++ b/mustache.js.nuspec @@ -2,7 +2,7 @@ mustache.js - 2.1.3 + 2.2.0 mustache.js Authors https://github.com/janl/mustache.js/blob/master/LICENSE http://mustache.github.com/ diff --git a/mustache.min.js b/mustache.min.js index 8760cbe35..f81cb0cf3 100644 --- a/mustache.min.js +++ b/mustache.min.js @@ -1 +1 @@ -(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(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){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function escapeHtml(string){return String(string).replace(/[&<>"'\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}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;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};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;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;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;while(value!=null&&index")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]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j":">",'"':""","'":"'","/":"/"};function escapeHtml(string){return String(string).replace(/[&<>"'\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}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;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};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;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;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;while(value!=null&&index")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]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j", "homepage": "https://github.com/janl/mustache.js", From b04249a4d6aebe019509451adb2aa7a000ecd5a3 Mon Sep 17 00:00:00 2001 From: David da Silva Date: Thu, 15 Oct 2015 12:21:29 +0200 Subject: [PATCH 011/172] Fix heading size in 2.2.0 CHANGELOG I'm sorry. :see_no_evil: --- CHANGELOG.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d44371857..b89eb44b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,7 +9,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Add Partials support to CLI, by [@palkan]. -## Changed +### Changed * Move install instructions to README's top, by [@mateusortiz] * Improved devhook install output, by [@ShashankaNataraj]. @@ -17,12 +17,12 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Linting CLI tool, by [@phillipj]. * npm 2.x and node v4 on Travis, by [@phillipj]. -## Fixes +### Fixes * Fix README spelling error to "aforementioned", by [@djchie]. * Equal error message test in .render() for server and browser, by [@phillipj]. -## Dependencies +### Dependencies * chai -> 3.3.0 * eslint -> 1.6.0 From 9f98c8f0a042d369e787afd38a08b60389cf7c98 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Fri, 16 Oct 2015 19:31:27 +0200 Subject: [PATCH 012/172] chore(package): update eslint to version 1.7.0 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 0d9ded71a..5e39d96ee 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "3.3.0", - "eslint": "1.6.0", + "eslint": "1.7.0", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From 93291266fefbdb109f9e6c1853ea955656aad2a6 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Fri, 16 Oct 2015 23:54:26 +0200 Subject: [PATCH 013/172] chore(package): update eslint to version 1.7.1 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5e39d96ee..56c69a04c 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "3.3.0", - "eslint": "1.7.0", + "eslint": "1.7.1", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From d6972127ee0ef6cd5ab8c40d6abb971c3ac9eb1f Mon Sep 17 00:00:00 2001 From: Michael Jackson Date: Fri, 16 Oct 2015 15:38:54 -0700 Subject: [PATCH 014/172] Update my username :) --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2233ab983..0941684ee 100644 --- a/README.md +++ b/README.md @@ -591,6 +591,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 From 320d0e629d8208f7a625092b1f081d1b363258ff Mon Sep 17 00:00:00 2001 From: Evan Lovely Date: Mon, 19 Oct 2015 12:16:44 -0700 Subject: [PATCH 015/172] Update README.md with proper grammar Past tense of "run" is "ran", not "runned". --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0941684ee..0abcc40c6 100644 --- a/README.md +++ b/README.md @@ -555,7 +555,7 @@ Then, you can run the test with: ### Browser tests -Browser tests are not included in `npm test` as they run for too long, although they are runned automatically on Travis when merged into master. Run browser tests locally in any browser: +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: $ npm run test-browser-local From ec8cd1415a19383bac8a81c1394f2dc086f4d4db Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Mon, 19 Oct 2015 23:13:59 +0200 Subject: [PATCH 016/172] chore(package): update eslint to version 1.7.2 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 56c69a04c..3997f8777 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "3.3.0", - "eslint": "1.7.1", + "eslint": "1.7.2", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From fed8a63a85dc8262031d2a237528559653b390e2 Mon Sep 17 00:00:00 2001 From: "yongxiang.li" Date: Wed, 21 Oct 2015 00:01:39 +0800 Subject: [PATCH 017/172] fix switch-case indent error --- mustache.js | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/mustache.js b/mustache.js index 935e007d5..18706aecb 100644 --- a/mustache.js +++ b/mustache.js @@ -267,19 +267,19 @@ 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); + 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); } } @@ -329,16 +329,16 @@ 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); + 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; From dda6c3c3dc28216753dce3574634fdf8edd9dfb6 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Wed, 21 Oct 2015 13:30:35 +0200 Subject: [PATCH 018/172] chore(package): update chai to version 3.4.0 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3997f8777..a53178c12 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "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.3.0", + "chai": "3.4.0", "eslint": "1.7.2", "mocha": "^2.1.0", "zuul": "^2.1.1" From c740c25960daf848203b86dc6f57fa5476adc885 Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Wed, 21 Oct 2015 19:14:28 +0200 Subject: [PATCH 019/172] chore(package): update eslint to version 1.7.3 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a53178c12..a3f429860 100644 --- a/package.json +++ b/package.json @@ -41,7 +41,7 @@ }, "devDependencies": { "chai": "3.4.0", - "eslint": "1.7.2", + "eslint": "1.7.3", "mocha": "^2.1.0", "zuul": "^2.1.1" }, From 21608715628920df700d9cf8d1235986ab372adf Mon Sep 17 00:00:00 2001 From: greenkeeperio-bot Date: Thu, 22 Oct 2015 18:40:48 +0200 Subject: [PATCH 020/172] chore(package): update zuul to version 3.7.0 http://greenkeeper.io/ --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a3f429860..850ad2032 100644 --- a/package.json +++ b/package.json @@ -43,7 +43,7 @@ "chai": "3.4.0", "eslint": "1.7.3", "mocha": "^2.1.0", - "zuul": "^2.1.1" + "zuul": "^3.7.0" }, "spm": { "main": "mustache.js", From 1ac4a9de5cbbadf86257b39db1d6237bc4fd0718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Antonio=20Chio?= Date: Sun, 11 Oct 2015 17:57:55 -0500 Subject: [PATCH 021/172] Remove syntax highlighting in README code sample --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ecb5ce54f..6bbd64b8c 100644 --- a/README.md +++ b/README.md @@ -119,7 +119,7 @@ View: Template: -```html +``` * {{name}} * {{age}} * {{company}} From b67970c7327ac33fc77ec6e6b7ded5c341fbdbf3 Mon Sep 17 00:00:00 2001 From: Nigel D'Souza Date: Tue, 27 Oct 2015 00:26:21 -0500 Subject: [PATCH 022/172] Extremely minor documentation update --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0abcc40c6..b83a577ec 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ mustache.js is a mature project, but it continues to actively invite maintainers ## Usage -Below is quick example how to use mustache.js: +Below is a quick example how to use mustache.js: ```js var view = { From dadbe203d5b3f66d7ea8f0443139a1973baa1143 Mon Sep 17 00:00:00 2001 From: David da Silva Date: Fri, 30 Oct 2015 19:41:56 +0100 Subject: [PATCH 023/172] Unpin chai and eslint versions greenkeeper.io will let us know if the minor/patch bumps break our code, so go wild. --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 850ad2032..a80b121a6 100644 --- a/package.json +++ b/package.json @@ -40,8 +40,8 @@ "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": "1.7.3", + "chai": "^3.4.0", + "eslint": "^1.7.3", "mocha": "^2.1.0", "zuul": "^3.7.0" }, From 378bcca8a5cfe4058f294a3dbb78e8755e8e0da5 Mon Sep 17 00:00:00 2001 From: Phillip Johnsen Date: Tue, 17 Nov 2015 09:14:29 +0100 Subject: [PATCH 024/172] Improve HTML escaping. This closes a couple of potential exploit scenarios. Backtick (`) for older IEs and equals (=) for unquoted attributes. Refs https://github.com/wycats/handlebars.js/commit/83b8e846a3569bd366cf0b6bdc1e4604d1a2077e Closes https://github.com/janl/mustache.js/pull/388 --- mustache.js | 6 ++++-- test/_files/escaped.js | 2 +- test/_files/escaped.txt | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/mustache.js b/mustache.js index 18706aecb..cad9ebb0a 100644 --- a/mustache.js +++ b/mustache.js @@ -63,11 +63,13 @@ '>': '>', '"': '"', "'": ''', - '/': '/' + '/': '/', + '`': '`', + '=': '=' }; function escapeHtml (string) { - return String(string).replace(/[&<>"'\/]/g, function fromEntityMap (s) { + return String(string).replace(/[&<>"'`=\/]/g, function fromEntityMap (s) { return entityMap[s]; }); } diff --git a/test/_files/escaped.js b/test/_files/escaped.js index cd77c1f49..e60095960 100644 --- a/test/_files/escaped.js +++ b/test/_files/escaped.js @@ -2,5 +2,5 @@ title: function () { return "Bear > Shark"; }, - entities: "" \"'<>/" + entities: "" \"'<>`=/" }) diff --git a/test/_files/escaped.txt b/test/_files/escaped.txt index c1527d510..182f99ee4 100644 --- a/test/_files/escaped.txt +++ b/test/_files/escaped.txt @@ -1,2 +1,2 @@

Bear > Shark

-And even &quot; "'<>/, but not " "'<>/. +And even &quot; "'<>`=/, but not " "'<>`=/. From 3460f1ef671dccaaec5a0ffe5a3c572225cc1e0a Mon Sep 17 00:00:00 2001 From: Simas Toleikis Date: Thu, 26 Nov 2015 11:25:10 +0200 Subject: [PATCH 025/172] Fix inconsistency in defining global mustache object. --- mustache.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mustache.js b/mustache.js index cad9ebb0a..56de2d5c3 100644 --- a/mustache.js +++ b/mustache.js @@ -12,7 +12,7 @@ define(['exports'], factory); // AMD } else { global.Mustache = {}; - factory(Mustache); // script, wsh, asp + factory(global.Mustache); // script, wsh, asp } }(this, function mustacheFactory (mustache) { From 1a391c9b2cd8681fca39b403f78bafd38b72843d Mon Sep 17 00:00:00 2001 From: Keith Rogers Date: Tue, 1 Dec 2015 22:49:26 +0000 Subject: [PATCH 026/172] Fix minor typo in docs --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 4151b175a..cbaf0113f 100644 --- a/README.md +++ b/README.md @@ -160,7 +160,7 @@ The most basic tag type is a simple variable. A `{{name}}` tag renders the value 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. -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 ["Set Delimiter'](https://github.com/janl/mustache.js#set-delimiter) section for more information about custom delimiters. +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 ["Set Delimiter"](https://github.com/janl/mustache.js#set-delimiter) section for more information about custom delimiters. View: From cd06b22dabdaeffe3e4c74ee02bd492a11bbb740 Mon Sep 17 00:00:00 2001 From: David da Silva Date: Sun, 13 Dec 2015 11:55:56 +0100 Subject: [PATCH 027/172] :ship: bump to version 2.2.1 --- CHANGELOG.md | 21 +++++++++++++++++++++ mustache.js | 2 +- mustache.js.nuspec | 2 +- mustache.min.js | 2 +- package.json | 2 +- 5 files changed, 25 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b89eb44b1..eb943252d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,20 @@ All notable changes to this project will be documented in this file. This project adheres to [Semantic Versioning](http://semver.org/). +## [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 @@ -159,6 +173,7 @@ This project adheres to [Semantic Versioning](http://semver.org/). * Fixed a bug that clashed with QUnit (thanks [@kannix]). * Added volo support (thanks [@guybedford]). +[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 @@ -194,20 +209,26 @@ This project adheres to [Semantic Versioning](http://semver.org/). [@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 [@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 [@kristijanmatic]: https://github.com/kristijanmatic [@mateusortiz]: https://github.com/mateusortiz [@mikesherov]: https://github.com/mikesherov [@mjackson]: https://github.com/mjackson [@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 [@ShashankaNataraj]: https://github.com/ShashankaNataraj +[@simast]: https://github.com/simast [@TiddoLangerak]: https://github.com/TiddoLangerak +[@Xcrucifier]: https://github.com/Xcrucifier [@yousefcisco]: https://github.com/yousefcisco diff --git a/mustache.js b/mustache.js index 56de2d5c3..53ec2723f 100644 --- a/mustache.js +++ b/mustache.js @@ -567,7 +567,7 @@ }; mustache.name = 'mustache.js'; - mustache.version = '2.2.0'; + mustache.version = '2.2.1'; mustache.tags = [ '{{', '}}' ]; // All high-level mustache.* functions use this writer. diff --git a/mustache.js.nuspec b/mustache.js.nuspec index 5b8d6a258..e2ad13358 100644 --- a/mustache.js.nuspec +++ b/mustache.js.nuspec @@ -2,7 +2,7 @@ mustache.js - 2.2.0 + 2.2.1 mustache.js Authors https://github.com/janl/mustache.js/blob/master/LICENSE http://mustache.github.com/ diff --git a/mustache.min.js b/mustache.min.js index f81cb0cf3..3e5080309 100644 --- a/mustache.min.js +++ b/mustache.min.js @@ -1 +1 @@ -(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(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){return typeof object==="function"}function typeStr(obj){return isArray(obj)?"array":typeof obj}function escapeRegExp(string){return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g,"\\$&")}function hasProperty(obj,propName){return obj!=null&&typeof obj==="object"&&propName in obj}var regExpTest=RegExp.prototype.test;function testRegExp(re,string){return regExpTest.call(re,string)}var nonSpaceRe=/\S/;function isWhitespace(string){return!testRegExp(nonSpaceRe,string)}var entityMap={"&":"&","<":"<",">":">",'"':""","'":"'","/":"/"};function escapeHtml(string){return String(string).replace(/[&<>"'\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}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;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};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;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;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;while(value!=null&&index")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]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j":">",'"':""","'":"'","/":"/","`":"`","=":"="};function escapeHtml(string){return String(string).replace(/[&<>"'`=\/]/g,function fromEntityMap(s){return entityMap[s]})}var whiteRe=/\s*/;var spaceRe=/\s+/;var equalsRe=/\s*=/;var curlyRe=/\s*\}/;var tagRe=/#|\^|\/|>|\{|&|=|!/;function parseTemplate(template,tags){if(!template)return[];var sections=[];var tokens=[];var spaces=[];var hasTag=false;var nonSpace=false;function stripSpace(){if(hasTag&&!nonSpace){while(spaces.length)delete tokens[spaces.pop()]}else{spaces=[]}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;value=scanner.scanUntil(openingTagRe);if(value){for(var i=0,valueLength=value.length;i0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}function Scanner(string){this.string=string;this.tail=string;this.pos=0}Scanner.prototype.eos=function eos(){return this.tail===""};Scanner.prototype.scan=function scan(re){var match=this.tail.match(re);if(!match||match.index!==0)return"";var string=match[0];this.tail=this.tail.substring(string.length);this.pos+=string.length;return string};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;return match};function Context(view,parentContext){this.view=view;this.cache={".":this.view};this.parent=parentContext}Context.prototype.push=function push(view){return new Context(view,this)};Context.prototype.lookup=function lookup(name){var cache=this.cache;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;while(value!=null&&index")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]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j", "homepage": "https://github.com/janl/mustache.js", From 8bfd6e4c60f61741b81478529eee7afd139f56bd Mon Sep 17 00:00:00 2001 From: wizawu Date: Fri, 16 Oct 2015 18:01:35 +0800 Subject: [PATCH 028/172] Add `output` argument to mustache bin --- bin/mustache | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bin/mustache b/bin/mustache index 6067e0b4b..430e8b937 100755 --- a/bin/mustache +++ b/bin/mustache @@ -16,13 +16,14 @@ while ((partialArgIndex = process.argv.indexOf('-p')) > -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