| @@ -12,7 +12,7 @@ | |||||
| var mustache = {}; | var mustache = {}; | ||||
| factory(mustache); | factory(mustache); | ||||
| if (typeof define === "function" && define.amd) { | if (typeof define === "function" && define.amd) { | ||||
| define(mustache); // AMD | define(mustache); // AMD | ||||
| } else { | } else { | ||||
| @@ -21,18 +21,6 @@ | |||||
| } | } | ||||
| }(this, function (mustache) { | }(this, function (mustache) { | ||||
| // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577 | |||||
| // See https://github.com/janl/mustache.js/issues/189 | |||||
| var RegExp_test = RegExp.prototype.test; | |||||
| function testRegExp(re, string) { | |||||
| return RegExp_test.call(re, string); | |||||
| } | |||||
| var nonSpaceRe = /\S/; | |||||
| function isWhitespace(string) { | |||||
| return !testRegExp(nonSpaceRe, string); | |||||
| } | |||||
| var Object_toString = Object.prototype.toString; | var Object_toString = Object.prototype.toString; | ||||
| var isArray = Array.isArray || function (object) { | var isArray = Array.isArray || function (object) { | ||||
| return Object_toString.call(object) === '[object Array]'; | return Object_toString.call(object) === '[object Array]'; | ||||
| @@ -46,6 +34,18 @@ | |||||
| return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); | return string.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&"); | ||||
| } | } | ||||
| // Workaround for https://issues.apache.org/jira/browse/COUCHDB-577 | |||||
| // See https://github.com/janl/mustache.js/issues/189 | |||||
| var RegExp_test = RegExp.prototype.test; | |||||
| function testRegExp(re, string) { | |||||
| return RegExp_test.call(re, string); | |||||
| } | |||||
| var nonSpaceRe = /\S/; | |||||
| function isWhitespace(string) { | |||||
| return !testRegExp(nonSpaceRe, string); | |||||
| } | |||||
| var entityMap = { | var entityMap = { | ||||
| "&": "&", | "&": "&", | ||||
| "<": "<", | "<": "<", | ||||
| @@ -100,8 +100,10 @@ | |||||
| * which the closing tag for that section begins. | * which the closing tag for that section begins. | ||||
| */ | */ | ||||
| function parseTemplate(template, tags) { | function parseTemplate(template, tags) { | ||||
| if (!template) | |||||
| return []; | |||||
| tags = tags || mustache.tags; | tags = tags || mustache.tags; | ||||
| template = template || ''; | |||||
| if (typeof tags === 'string') | if (typeof tags === 'string') | ||||
| tags = tags.split(spaceRe); | tags = tags.split(spaceRe); | ||||
| @@ -155,7 +157,9 @@ | |||||
| } | } | ||||
| // Match the opening tag. | // Match the opening tag. | ||||
| if (!scanner.scan(tagRes[0])) break; | |||||
| if (!scanner.scan(tagRes[0])) | |||||
| break; | |||||
| hasTag = true; | hasTag = true; | ||||
| // Get the tag type. | // Get the tag type. | ||||