Comparing version 2.2.1 to 2.3.0
@@ -6,2 +6,31 @@ # Change Log | ||
## [2.3.0] / 8 November 2016 | ||
### Minor | ||
* [#540]: Add optional `output` argument to mustache CLI, by [@wizawu]. | ||
* [#597]: Add compatibility with amdclean, by [@mightyplow]. | ||
### Dev | ||
* [#553]: Assert `null` lookup when rendering an unescaped value, by [@dasilvacontin]. | ||
* [#580], [#610]: Ignore eslint for greenkeeper updates, by [@phillipj]. | ||
* [#560]: Fix CLI tests for Windows, by [@kookookchoozeus]. | ||
* Run browser tests w/node v4, by [@phillipj]. | ||
### Docs | ||
* [#542]: Add API documentation to README, by [@tomekwi]. | ||
* [#546]: Add missing syntax highlighting to README code blocks, by [@pra85]. | ||
* [#569]: Update Ctemplate links in README, by [@mortonfox]. | ||
* [#592]: Change "loadUser" to "loadUser()" in README, by [@Flaque]. | ||
* [#593]: Adding doctype to HTML code example in README, by [@calvinf]. | ||
### Dependencies | ||
* eslint -> 2.2.0. Breaking changes fix by [@phillipj]. [#548] | ||
* eslint -> 2.5.1. | ||
* mocha -> 3.0.2. | ||
* zuul -> 3.11.0. | ||
## [2.2.1] / 13 December 2015 | ||
@@ -177,2 +206,3 @@ | ||
[2.3.0]: https://github.com/janl/mustache.js/compare/v2.2.1...v2.3.0 | ||
[2.2.1]: https://github.com/janl/mustache.js/compare/v2.2.0...v2.2.1 | ||
@@ -207,5 +237,18 @@ [2.2.0]: https://github.com/janl/mustache.js/compare/v2.1.3...v2.2.0 | ||
[#466]: https://github.com/janl/mustache.js/issues/466 | ||
[#540]: https://github.com/janl/mustache.js/issues/540 | ||
[#542]: https://github.com/janl/mustache.js/issues/542 | ||
[#546]: https://github.com/janl/mustache.js/issues/546 | ||
[#548]: https://github.com/janl/mustache.js/issues/548 | ||
[#553]: https://github.com/janl/mustache.js/issues/553 | ||
[#560]: https://github.com/janl/mustache.js/issues/560 | ||
[#569]: https://github.com/janl/mustache.js/issues/569 | ||
[#580]: https://github.com/janl/mustache.js/issues/580 | ||
[#592]: https://github.com/janl/mustache.js/issues/592 | ||
[#593]: https://github.com/janl/mustache.js/issues/593 | ||
[#597]: https://github.com/janl/mustache.js/issues/597 | ||
[#610]: https://github.com/janl/mustache.js/issues/610 | ||
[@afc163]: https://github.com/afc163 | ||
[@Andersos]: https://github.com/Andersos | ||
[@calvinf]: https://github.com/calvinf | ||
[@cmbuckley]: https://github.com/cmbuckley | ||
@@ -217,2 +260,3 @@ [@cweider]: https://github.com/cweider | ||
[@fallenice]: https://github.com/fallenice | ||
[@Flaque]: https://github.com/Flaque | ||
[@guybedford]: https://github.com/guybedford | ||
@@ -225,6 +269,9 @@ [@imagentleman]: https://github.com/imagentleman | ||
[@kkirsche]: https://github.com/kkirsche | ||
[@kookookchoozeus]: https://github.com/kookookchoozeus | ||
[@kristijanmatic]: https://github.com/kristijanmatic | ||
[@mateusortiz]: https://github.com/mateusortiz | ||
[@mightyplow]: https://github.com/mightyplow | ||
[@mikesherov]: https://github.com/mikesherov | ||
[@mjackson]: https://github.com/mjackson | ||
[@mortonfox]: https://github.com/mortonfox | ||
[@nagaozen]: https://github.com/nagaozen | ||
@@ -235,6 +282,9 @@ [@norfish]: https://github.com/norfish | ||
[@phillipj]: https://github.com/phillipj | ||
[@pra85]: https://github.com/pra85 | ||
[@ShashankaNataraj]: https://github.com/ShashankaNataraj | ||
[@simast]: https://github.com/simast | ||
[@TiddoLangerak]: https://github.com/TiddoLangerak | ||
[@tomekwi]: https://github.com/tomekwi | ||
[@wizawu]: https://github.com/wizawu | ||
[@Xcrucifier]: https://github.com/Xcrucifier | ||
[@yousefcisco]: https://github.com/yousefcisco |
@@ -570,3 +570,3 @@ /*! | ||
mustache.name = 'mustache.js'; | ||
mustache.version = '2.2.1'; | ||
mustache.version = '2.3.0'; | ||
mustache.tags = [ '{{', '}}' ]; | ||
@@ -630,2 +630,3 @@ | ||
return mustache; | ||
})); |
@@ -1,1 +0,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(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){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;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length)}else{nonSpace=true}tokens.push(["text",chr,start,start+1]);start+=1;if(chr==="\n")stripSpace()}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||"name";scanner.scan(whiteRe);if(type==="="){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type==="{"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type="&"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error("Unclosed tag at "+scanner.pos);token=[type,value,start,scanner.pos];tokens.push(token);if(type==="#"||type==="^"){sections.push(token)}else if(type==="/"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section "'+value+'" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}else if(type==="name"||type==="{"||type==="&"){nonSpace=true}else if(type==="="){compileTags(value)}}openSection=sections.pop();if(openSection)throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]==="text"&&lastToken&&lastToken[0]==="text"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case"#":case"^":collector.push(token);sections.push(token);collector=token[4]=[];break;case"/":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}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<names.length){if(index===names.length-1)lookupHit=hasProperty(value,names[index]);value=value[names[index++]]}}else{value=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit)break;context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.cache={}}Writer.prototype.clearCache=function clearCache(){this.cache={}};Writer.prototype.parse=function parse(template,tags){var cache=this.cache;var tokens=cache[template];if(tokens==null)tokens=cache[template]=parseTemplate(template,tags);return tokens};Writer.prototype.render=function render(template,view,partials){var tokens=this.parse(template);var context=view instanceof Context?view:new Context(view);return this.renderTokens(tokens,context,partials,template)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate){var buffer="";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol==="#")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol==="^")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===">")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value==="object"||typeof value==="string"||typeof value==="number"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!=="string")throw new Error("Cannot use higher-order sections without the original template");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.renderPartial=function renderPartial(token,context,partials){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null)return this.renderTokens(this.parse(value),context,partials,value)};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};mustache.name="mustache.js";mustache.version="2.2.1";mustache.tags=["{{","}}"];var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials){if(typeof template!=="string"){throw new TypeError('Invalid template! Template should be a "string" '+'but "'+typeStr(template)+'" was given as the first '+"argument for mustache#render(template, view, partials)")}return defaultWriter.render(template,view,partials)};mustache.to_html=function to_html(template,view,partials,send){var result=mustache.render(template,view,partials);if(isFunction(send)){send(result)}else{return result}};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer}); | ||
(function defineMustache(global,factory){if(typeof exports==="object"&&exports&&typeof exports.nodeName!=="string"){factory(exports)}else if(typeof define==="function"&&define.amd){define(["exports"],factory)}else{global.Mustache={};factory(global.Mustache)}})(this,function mustacheFactory(mustache){var objectToString=Object.prototype.toString;var isArray=Array.isArray||function isArrayPolyfill(object){return objectToString.call(object)==="[object Array]"};function isFunction(object){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;i<valueLength;++i){chr=value.charAt(i);if(isWhitespace(chr)){spaces.push(tokens.length)}else{nonSpace=true}tokens.push(["text",chr,start,start+1]);start+=1;if(chr==="\n")stripSpace()}}if(!scanner.scan(openingTagRe))break;hasTag=true;type=scanner.scan(tagRe)||"name";scanner.scan(whiteRe);if(type==="="){value=scanner.scanUntil(equalsRe);scanner.scan(equalsRe);scanner.scanUntil(closingTagRe)}else if(type==="{"){value=scanner.scanUntil(closingCurlyRe);scanner.scan(curlyRe);scanner.scanUntil(closingTagRe);type="&"}else{value=scanner.scanUntil(closingTagRe)}if(!scanner.scan(closingTagRe))throw new Error("Unclosed tag at "+scanner.pos);token=[type,value,start,scanner.pos];tokens.push(token);if(type==="#"||type==="^"){sections.push(token)}else if(type==="/"){openSection=sections.pop();if(!openSection)throw new Error('Unopened section "'+value+'" at '+start);if(openSection[1]!==value)throw new Error('Unclosed section "'+openSection[1]+'" at '+start)}else if(type==="name"||type==="{"||type==="&"){nonSpace=true}else if(type==="="){compileTags(value)}}openSection=sections.pop();if(openSection)throw new Error('Unclosed section "'+openSection[1]+'" at '+scanner.pos);return nestTokens(squashTokens(tokens))}function squashTokens(tokens){var squashedTokens=[];var token,lastToken;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];if(token){if(token[0]==="text"&&lastToken&&lastToken[0]==="text"){lastToken[1]+=token[1];lastToken[3]=token[3]}else{squashedTokens.push(token);lastToken=token}}}return squashedTokens}function nestTokens(tokens){var nestedTokens=[];var collector=nestedTokens;var sections=[];var token,section;for(var i=0,numTokens=tokens.length;i<numTokens;++i){token=tokens[i];switch(token[0]){case"#":case"^":collector.push(token);sections.push(token);collector=token[4]=[];break;case"/":section=sections.pop();section[5]=token[2];collector=sections.length>0?sections[sections.length-1][4]:nestedTokens;break;default:collector.push(token)}}return nestedTokens}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<names.length){if(index===names.length-1)lookupHit=hasProperty(value,names[index]);value=value[names[index++]]}}else{value=context.view[name];lookupHit=hasProperty(context.view,name)}if(lookupHit)break;context=context.parent}cache[name]=value}if(isFunction(value))value=value.call(this.view);return value};function Writer(){this.cache={}}Writer.prototype.clearCache=function clearCache(){this.cache={}};Writer.prototype.parse=function parse(template,tags){var cache=this.cache;var tokens=cache[template];if(tokens==null)tokens=cache[template]=parseTemplate(template,tags);return tokens};Writer.prototype.render=function render(template,view,partials){var tokens=this.parse(template);var context=view instanceof Context?view:new Context(view);return this.renderTokens(tokens,context,partials,template)};Writer.prototype.renderTokens=function renderTokens(tokens,context,partials,originalTemplate){var buffer="";var token,symbol,value;for(var i=0,numTokens=tokens.length;i<numTokens;++i){value=undefined;token=tokens[i];symbol=token[0];if(symbol==="#")value=this.renderSection(token,context,partials,originalTemplate);else if(symbol==="^")value=this.renderInverted(token,context,partials,originalTemplate);else if(symbol===">")value=this.renderPartial(token,context,partials,originalTemplate);else if(symbol==="&")value=this.unescapedValue(token,context);else if(symbol==="name")value=this.escapedValue(token,context);else if(symbol==="text")value=this.rawValue(token);if(value!==undefined)buffer+=value}return buffer};Writer.prototype.renderSection=function renderSection(token,context,partials,originalTemplate){var self=this;var buffer="";var value=context.lookup(token[1]);function subRender(template){return self.render(template,context,partials)}if(!value)return;if(isArray(value)){for(var j=0,valueLength=value.length;j<valueLength;++j){buffer+=this.renderTokens(token[4],context.push(value[j]),partials,originalTemplate)}}else if(typeof value==="object"||typeof value==="string"||typeof value==="number"){buffer+=this.renderTokens(token[4],context.push(value),partials,originalTemplate)}else if(isFunction(value)){if(typeof originalTemplate!=="string")throw new Error("Cannot use higher-order sections without the original template");value=value.call(context.view,originalTemplate.slice(token[3],token[5]),subRender);if(value!=null)buffer+=value}else{buffer+=this.renderTokens(token[4],context,partials,originalTemplate)}return buffer};Writer.prototype.renderInverted=function renderInverted(token,context,partials,originalTemplate){var value=context.lookup(token[1]);if(!value||isArray(value)&&value.length===0)return this.renderTokens(token[4],context,partials,originalTemplate)};Writer.prototype.renderPartial=function renderPartial(token,context,partials){if(!partials)return;var value=isFunction(partials)?partials(token[1]):partials[token[1]];if(value!=null)return this.renderTokens(this.parse(value),context,partials,value)};Writer.prototype.unescapedValue=function unescapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return value};Writer.prototype.escapedValue=function escapedValue(token,context){var value=context.lookup(token[1]);if(value!=null)return mustache.escape(value)};Writer.prototype.rawValue=function rawValue(token){return token[1]};mustache.name="mustache.js";mustache.version="2.3.0";mustache.tags=["{{","}}"];var defaultWriter=new Writer;mustache.clearCache=function clearCache(){return defaultWriter.clearCache()};mustache.parse=function parse(template,tags){return defaultWriter.parse(template,tags)};mustache.render=function render(template,view,partials){if(typeof template!=="string"){throw new TypeError('Invalid template! Template should be a "string" '+'but "'+typeStr(template)+'" was given as the first '+"argument for mustache#render(template, view, partials)")}return defaultWriter.render(template,view,partials)};mustache.to_html=function to_html(template,view,partials,send){var result=mustache.render(template,view,partials);if(isFunction(send)){send(result)}else{return result}};mustache.escape=escapeHtml;mustache.Scanner=Scanner;mustache.Context=Context;mustache.Writer=Writer;return mustache}); |
{ | ||
"name": "mustache", | ||
"version": "2.2.1", | ||
"version": "2.3.0", | ||
"description": "Logic-less {{mustache}} templates with JavaScript", | ||
@@ -44,5 +44,5 @@ "author": "mustache.js Authors <http://github.com/janl/mustache.js>", | ||
"chai": "^3.4.0", | ||
"eslint": "^1.7.3", | ||
"mocha": "^2.1.0", | ||
"zuul": "^3.7.0" | ||
"eslint": "^2.5.1", | ||
"mocha": "^3.0.2", | ||
"zuul": "^3.11.0" | ||
}, | ||
@@ -56,3 +56,8 @@ "spm": { | ||
}, | ||
"greenkeeper": { | ||
"ignore": [ | ||
"eslint" | ||
] | ||
}, | ||
"license": "MIT" | ||
} |
105
README.md
@@ -114,2 +114,21 @@ # mustache.js - Logic-less {{mustache}} templates with JavaScript | ||
## API | ||
Following is an [rtype](https://git.io/rtype) signature of the most commonly used functions. | ||
```js | ||
Mustache.render( | ||
template : String, | ||
view : Object, | ||
partials? : Object, | ||
) => String | ||
Mustache.parse( | ||
template : String, | ||
tags = ['{{', '}}'] : Tags, | ||
) => String | ||
interface Tags [String, String] | ||
``` | ||
## Templates | ||
@@ -126,4 +145,5 @@ | ||
```html | ||
<!DOCTYPE HTML> | ||
<html> | ||
<body onload="loadUser"> | ||
<body onload="loadUser()"> | ||
<div id="target">Loading...</div> | ||
@@ -165,3 +185,3 @@ <script id="template" type="x-tmpl-mustache"> | ||
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 [Custom Delimiters](#custom-delimiters) section for more information. | ||
@@ -479,4 +499,27 @@ View: | ||
### Set Delimiter | ||
### Custom Delimiters | ||
Custom delimiters can be used in place of `{{` and `}}` by setting the new values in JavaScript or in templates. | ||
#### Setting in JavaScript | ||
The `Mustache.tags` property holds an array consisting of the opening and closing tag values. Set custom values by passing a new array of tags to `parse()`, which gets honored over the default values, or by overriding the `tags` property itself: | ||
```js | ||
var customTags = [ '<%', '%>' ]; | ||
``` | ||
##### Pass Value into Parse Method | ||
```js | ||
Mustache.parse(template, customTags); | ||
``` | ||
##### Override Tags Property | ||
```js | ||
Mustache.tags = customTags; | ||
// Subsequent parse() and render() calls will use customTags | ||
``` | ||
#### Setting in Templates | ||
Set Delimiter tags start with an equals sign and change the tag delimiters from `{{` and `}}` to custom strings. | ||
@@ -486,3 +529,3 @@ | ||
``` | ||
```html+erb | ||
* {{ default_tags }} | ||
@@ -497,3 +540,3 @@ {{=<% %>=}} | ||
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](https://htmlpreview.github.io/?https://raw.githubusercontent.com/OlafvdSpek/ctemplate/master/doc/howto.html), this "is useful for languages like TeX, where double-braces may occur in the text and are awkward to use for markup." | ||
@@ -524,9 +567,9 @@ Custom delimiters may not contain whitespace or the equals sign. | ||
These may be built using [Rake](http://rake.rubyforge.org/) and one of the following commands: | ||
$ rake jquery | ||
$ rake mootools | ||
$ rake dojo | ||
$ rake yui3 | ||
$ rake qooxdoo | ||
```bash | ||
$ rake jquery | ||
$ rake mootools | ||
$ rake dojo | ||
$ rake yui3 | ||
$ rake qooxdoo | ||
``` | ||
## Testing | ||
@@ -537,14 +580,14 @@ | ||
You also need to install the sub module containing [Mustache specifications](http://github.com/mustache/spec) in the project root. | ||
$ git submodule init | ||
$ git submodule update | ||
```bash | ||
$ git submodule init | ||
$ git submodule update | ||
``` | ||
Install dependencies. | ||
$ npm install | ||
```bash | ||
$ npm install | ||
``` | ||
Then run the tests. | ||
$ npm test | ||
```bash | ||
$ npm test | ||
``` | ||
The test suite consists of both unit and integration tests. If a template isn't rendering correctly for you, you can make a test for it by doing the following: | ||
@@ -561,11 +604,11 @@ | ||
Then, you can run the test with: | ||
$ TEST=mytest npm run test-render | ||
```bash | ||
$ TEST=mytest npm run test-render | ||
``` | ||
### Browser tests | ||
Browser tests are not included in `npm test` as they run for too long, although they are ran automatically on Travis when merged into master. Run browser tests locally in any browser: | ||
$ npm run test-browser-local | ||
```bash | ||
$ npm run test-browser-local | ||
``` | ||
then point your browser to `http://localhost:8080/__zuul` | ||
@@ -578,5 +621,5 @@ | ||
Ensure to have a recent version of npm installed. While developing this project requires npm with support for `^` version ranges. | ||
$ npm install -g npm | ||
```bash | ||
$ npm install -g npm | ||
``` | ||
## Thanks | ||
@@ -583,0 +626,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
69860
561
640