Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Socket
Sign inDemoInstall

vash

Package Overview
Dependencies
Maintainers
1
Versions
81
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

vash - npm Package Compare versions

Comparing version 0.7.9-7 to 0.7.10-2

statedtest.sh

2

build/vash-runtime-all.js
/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -4,0 +4,0 @@ * https://github.com/kirbysayshi/vash

/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -4,0 +4,0 @@ * https://github.com/kirbysayshi/vash

/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -4,0 +4,0 @@ * https://github.com/kirbysayshi/vash

/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -4,0 +4,0 @@ * https://github.com/kirbysayshi/vash

/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -46,3 +46,2 @@ * https://github.com/kirbysayshi/vash

,HTML_TAG_OPEN = 'HTML_TAG_OPEN'
,HTML_TAG_VOID_OPEN = 'HTML_TAG_VOID_OPEN'
,HTML_TAG_VOID_CLOSE = 'HTML_TAG_VOID_CLOSE'

@@ -136,6 +135,4 @@ ,IDENTIFIER = 'IDENTIFIER'

,reEmail = /([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/
,reSelfClosing = /^(<[a-zA-Z@]+(?:\s+\S+)*\s*\/>)/
var tok = this.scan( reSelfClosing, HTML_TAG_VOID_OPEN )
|| this.scan( reHtml, HTML_TAG_OPEN );
var tok = this.scan( reHtml, HTML_TAG_OPEN );

@@ -288,3 +285,2 @@ if( tok ){

vQuery.fn.tagName = null;
vQuery.fn.tagVoid = null;

@@ -743,3 +739,2 @@ vQuery.fn.beget = function(mode, tagName){

case HTML_TAG_OPEN:
case HTML_TAG_VOID_OPEN:
tagName = curr.val.match(/^<([^\/ >]+)/i);

@@ -758,11 +753,4 @@

// mark this ast as void, to enable recognition of HTML_TAG_VOID_CLOSE,
// which is otherwise generic
if(curr.type === HTML_TAG_VOID_OPEN){
this.ast.tagVoid = this.ast.tagName;
}
if(
HTML_TAG_VOID_OPEN === curr.type
|| HTML_TAG_OPEN === curr.type
HTML_TAG_OPEN === curr.type
|| this.options.saveTextTag

@@ -806,12 +794,4 @@ ){

case HTML_TAG_VOID_CLOSE:
// this should only be a valid token if tagVoid is defined, meaning
// HTML_TAG_VOID_OPEN was previously found within this markup block
if(this.ast.tagVoid){
this.ast.push(curr);
this.ast = this.ast.parent;
} else {
this.tokens.push(curr); // defer
}
this.ast.push(curr);
this.ast = this.ast.parent;
break;

@@ -868,3 +848,2 @@

case TEXT_TAG_CLOSE:
case HTML_TAG_VOID_OPEN:
case HTML_TAG_OPEN:

@@ -2287,2 +2266,2 @@ case HTML_TAG_CLOSE:

return exports;
}({ "version": "0.7.9-7" }));
}({ "version": "0.7.10-2" }));
/**
* Vash - JavaScript Template Parser, v0.7.9-7
* Vash - JavaScript Template Parser, v0.7.10-2
*

@@ -8,2 +8,2 @@ * https://github.com/kirbysayshi/vash

* MIT License (LICENSE)
*/void 0,function(a){typeof define=="function"&&define.amd?define(a):typeof module=="object"&&module.exports?module.exports=a:window.vash=a}(function(a){function S(a,b,c){this.ast=a,this.originalMarkup=b||"",this.options=c||{},this.reQuote=/(['"])/gi,this.reEscapedQuote=/\\+(["'])/gi,this.reLineBreak=/\r?\n/gi,this.reHelpersName=/HELPERSNAME/g,this.reModelName=/MODELNAME/g,this.reOriginalMarkup=/ORIGINALMARKUP/g,this.buffer=[]}function N(a,b){this.options=b||{},this.tokens=a,this.ast=M(O),this.prevTokens=[],this.inCommentLine=!1}function L(a){this.input=this.originalInput=a.replace(/^\uFEFF/,"").replace(/\r\n|\r/g,"\n"),this.lineno=1,this.charno=0}var b=a,c="AT",d="ASSIGN_OPERATOR",e="AT_COLON",f="AT_STAR_CLOSE",g="AT_STAR_OPEN",h="BACKSLASH",i="BRACE_CLOSE",j="BRACE_OPEN",k="CONTENT",l="DOUBLE_QUOTE",m="EMAIL",n="ESCAPED_QUOTE",o="FORWARD_SLASH",p="FUNCTION",q="HARD_PAREN_CLOSE",r="HARD_PAREN_OPEN",s="HTML_TAG_CLOSE",t="HTML_TAG_OPEN",u="HTML_TAG_VOID_OPEN",v="HTML_TAG_VOID_CLOSE",w="IDENTIFIER",x="KEYWORD",y="LOGICAL",z="NEWLINE",A="NUMERIC_CONTENT",B="OPERATOR",C="PAREN_CLOSE",D="PAREN_OPEN",E="PERIOD",F="SINGLE_QUOTE",G="TEXT_TAG_CLOSE",H="TEXT_TAG_OPEN",I="WHITESPACE",J={};J[g]=f,J[j]=i,J[l]=l,J[r]=q,J[D]=C,J[F]=F,J[e]=z,J[o]=o;var K=[m,/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:ca|co\.uk|com|edu|net|org))\b/,g,/^(@\*)/,f,/^(\*@)/,e,/^(@\:)/,c,/^(@)/,D,/^(\()/,C,/^(\))/,r,/^(\[)/,q,/^(\])/,j,/^(\{)/,i,/^(\})/,H,/^(<text>)/,G,/^(<\/text>)/,t,function(){var a=/^(<[a-zA-Z@]+?[^>]*?["a-zA-Z]*>)/,b=/([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/,c=/^(<[a-zA-Z@]+(?:\s+\S+)*\s*\/>)/,d=this.scan(c,u)||this.scan(a,t);d&&(this.spewIf(d,b),this.spewIf(d,/(@)/),this.spewIf(d,/(\/\s*>)/));return d},s,/^(<\/[^>@\b]+?>)/,v,/^(\/\s*>)/,E,/^(\.)/,z,function(){var a=this.scan(/^(\n)/,z);a&&(this.lineno++,this.charno=0);return a},I,/^(\s)/,p,/^(function)(?![\d\w])/,x,/^(case|catch|do|else|finally|for|function|goto|if|instanceof|return|switch|try|typeof|var|while|with)(?![\d\w])/,w,/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/,o,/^(\/)/,B,/^(===|!==|==|!==|>>>|<<|>>|>=|<=|>|<|\+|-|\/|\*|\^|%|\:|\?)/,d,/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=|=)/,y,/^(&&|\|\||&|\||\^)/,n,/^(\\+['"])/,h,/^(\\)/,l,/^(\")/,F,/^(\')/,A,/^([0-9]+)/,k,/^([^\s})@.]+?)/];L.prototype={scan:function(a,b){var c,d;if(c=a.exec(this.input)){this.input=this.input.substr(c[1].length),d={type:b,line:this.lineno,chr:this.charno,val:c[1]||"",toString:function(){return"["+this.type+" ("+this.line+","+this.chr+"): "+this.val+"]"}},this.charno+=c[0].length;return d}},spewIf:function(a,b){var c,d,e;a&&(c=b.exec(a.val),c&&(d=a.val.indexOf(c[1]),e=a.val.substring(d),this.input=e+this.input,this.charno-=e.length,a.val=a.val.substring(0,d)));return a},advance:function(){var a,b,c,d;for(a=0;a<K.length;a+=2){c=K[a+1],c.displayName=K[a],typeof c=="function"&&(d=c.call(this)),typeof c.exec=="function"&&(d=this.scan(c,K[a]));if(d)return d}}};var M=function(a){return new M.fn.init(a)};M.prototype.init=function(a){typeof a=="string"&&(this.mode=a),this.maxCheck()},M.fn=M.prototype.init.prototype=M.prototype,M.fn.vquery="yep",M.fn.constructor=M,M.fn.length=0,M.fn.parent=null,M.fn.mode=null,M.fn.tagName=null,M.fn.tagVoid=null,M.fn.beget=function(a,b){var c=M(a);c.parent=this,this.push(c),b&&(c.tagName=b),this.maxCheck();return c},M.fn.closest=function(a,b){var c=this;while(c)if(c.tagName!==b&&c.parent)c=c.parent;else break;return c},M.fn.pushFlatten=function(a){var b=a,c,d;while(b.length===1&&b[0].vquery)b=b[0];if(b.mode!==O)this.push(b);else for(c=0;c<b.length;c++)this.push(b[c]);this.maxCheck();return this},M.fn.push=function(a){M.isArray(a)?(a.vquery&&a.forEach(function(a){a.parent=this},this),Array.prototype.push.apply(this,a)):(a.vquery&&(a.parent=this),Array.prototype.push.call(this,a)),this.maxCheck();return this.length},M.fn.root=function(){var a=this;while(a&&a.parent&&(a=a.parent));return a},M.fn.toTreeString=function(){function c(d){var e,f;a.push(Array(b).join(" |")+" +"+d.mode+" "+(d.tagName||"")),b+=1,e=d.slice();while(f=e.shift())f.vquery===M.fn.vquery?c(f):a.push(Array(b).join(" |")+" "+(f?f.toString().replace(/(\r|\n)/g,""):"[empty]"));b-=1,a.push(Array(b).join(" |")+" -"+d.mode+" "+(d.tagName||""))}var a=[],b=1;c(this);return a.join("\n")},M.fn.maxCheck=function(a){if(this.length>=M.maxSize){var b=new Error;b.message="Maximum number of elements exceeded.\nThis is typically caused by an unmatched character or tag. Parse tree follows:\n"+this.toTreeString(),b.name="vQueryDepthException";throw b}},M.maxSize=1e5,M.fn.flatten=function(){var a;return this.reduce(function b(c,d,e,f){if(d.vquery){c.push({type:"META",val:"START"+d.mode,tagName:d.tagName}),a=d.reduce(b,c),a.push({type:"META",val:"END"+d.mode,tagName:d.tagName});return a}d.mode=f.mode,c.push(d);return c},[])},M.reconstitute=function(a){return a.reduce(function b(a,b,c,d){b.type==="META"?a=a.parent:(b.mode!==a.mode&&(a=a.beget(b.mode,b.tagName)),a.push(b));return a},M(O))},M.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"},M.extend=function(a){var b,c,d;for(c=1;c<arguments.length;c++){b=arguments[c];for(d in b)a[d]=b[d]}return a},M.takeMethodsFromArray=function(){var a=["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"],b=[],c;for(var d=0;d<a.length;d++){c=a[d];if(typeof b[c]=="function")M.fn[c]||function(a){M.fn[a]=function(){return b[a].apply(this,Array.prototype.slice.call(arguments,0))}}(c);else throw new Error("Vash requires ES5 array iteration methods, missing: "+c)}},M.takeMethodsFromArray();var O="PROGRAM",P="MARKUP",Q="BLOCK",R="EXPRESSION";N.prototype={parse:function(){var a,b,c,d;while(this.prevTokens.push(a),a=this.tokens.pop()){this.options.debugParser&&console.log(this.ast&&this.ast.mode,a.type,a.toString(),a.val);if(this.ast.mode===O||this.ast.mode===null)this.ast=this.ast.beget(this.options.initialMode||P),this.options.initialMode===R&&(this.ast=this.ast.beget(R));if(this.ast.mode===P){this.handleMKP(a);continue}if(this.ast.mode===Q){this.handleBLK(a);continue}if(this.ast.mode===R){this.handleEXP(a);continue}}this.ast=this.ast.root(),this.options.debugParser&&!this.options.initialMode&&(console.log(this.ast.toString()),console.log(this.ast.toTreeString()));return this.ast},exceptionFactory:function(a,b,c){b=="UNMATCHED"&&(a.name="UnmatchedCharacterError",this.ast=this.ast.root(),c&&(a.message="Unmatched "+c.type+" at line "+c.line+", character "+c.chr+". Value: "+c.val+"\n "+this.ast.toTreeString(),a.lineNumber=c.line));return a},advanceUntilNot:function(a){var b,c,d=[];while(c=this.tokens[this.tokens.length-1])if(c.type===a)b=this.tokens.pop(),d.push(b);else break;return d},advanceUntilMatched:function(a,b,c,d,e){var f=a,g=null,h=0,i=0,j=[];while(f){f.type===b?g&&g.type!==d&&b!==c||!g?h++:b===c&&g.type!==d&&i++:f.type===c&&(i++,g&&g.type===e&&i--),j.push(f);if(h===i)break;g=f,f=this.tokens.pop();if(!f)throw this.exceptionFactory(new Error,"UNMATCHED",a)}return j.reverse()},subParse:function(a,b,d){var e,f,g,h=M.extend({},this.options);h.initialMode=b,e=this.advanceUntilMatched(a,a.type,J[a.type],null,c),e.pop(),f=e.shift(),d||this.ast.push(a),g=new N(e,h),g.parse(),d&&(g.ast[0].unshift(a),g.ast[0].push(f)),this.ast.pushFlatten(g.ast),d||this.ast.push(f)},handleMKP:function(a){var b=this.tokens[this.tokens.length-1],d=this.tokens[this.tokens.length-2],i=null,k;switch(a.type){case g:this.advanceUntilMatched(a,g,f,c,c);break;case c:if(b){this.options.saveAT&&this.ast.push(a);switch(b.type){case D:case w:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(R);break;case x:case p:case j:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(Q);break;case c:case e:b.type="CONTENT",this.ast.push(this.tokens.pop());break;default:this.ast.push(this.tokens.pop())}}break;case H:case t:case u:i=a.val.match(/^<([^\/ >]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),this.ast.tagName?this.ast=this.ast.beget(P,i[1]):this.ast.tagName=i[1],a.type===u&&(this.ast.tagVoid=this.ast.tagName),(u===a.type||t===a.type||this.options.saveTextTag)&&this.ast.push(a);break;case G:case s:i=a.val.match(/^<\/([^>]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),k=this.ast.closest(P,i[1]),k!==null&&k.tagName===i[1]&&(this.ast=k),(s===a.type||this.options.saveTextTag)&&this.ast.push(a),this.ast.parent&&this.ast.parent.mode===Q&&(this.ast=this.ast.parent);break;case v:this.ast.tagVoid?(this.ast.push(a),this.ast=this.ast.parent):this.tokens.push(a);break;case h:a.val+="\\",this.ast.push(a);break;default:this.ast.push(a)}},handleBLK:function(a){var b=this.tokens[this.tokens.length-1],d,i,m,n,q,r,v;switch(a.type){case c:b.type!==c&&!this.inCommentLine?(this.tokens.push(a),this.ast=this.ast.beget(P)):(b.type=k,this.ast.push(b),this.tokens.pop());break;case g:this.advanceUntilMatched(a,g,f,c,c);break;case e:this.subParse(a,P,!0);break;case H:case G:case u:case t:case s:this.ast=this.ast.beget(P),this.tokens.push(a);break;case o:case F:case l:a.type===o&&b&&b.type===o&&(this.inCommentLine=!0),this.inCommentLine?this.ast.push(a):(n=this.advanceUntilMatched(a,a.type,J[a.type],h,h).map(function(a){a.type===c&&(a.type=k);return a}),this.ast.pushFlatten(n.reverse()));break;case z:this.inCommentLine&&(this.inCommentLine=!1),this.ast.push(a);break;case j:case D:d=this.options.favorText&&a.type===j?P:Q,this.subParse(a,d),n=this.advanceUntilNot(I),b=this.tokens[this.tokens.length-1],b&&b.type!==x&&b.type!==p&&b.type!==j&&a.type!==D?(this.tokens.push.apply(this.tokens,n.reverse()),this.ast=this.ast.parent):this.ast.push(n);break;default:this.ast.push(a)}},handleEXP:function(a){var b=null,e,f,g,i,k,m,n;switch(a.type){case x:case p:this.ast=this.ast.beget(Q),this.tokens.push(a);break;case I:case y:case d:case B:case A:this.ast.parent&&this.ast.parent.mode===R?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;case w:this.ast.push(a);break;case F:case l:this.ast.parent&&this.ast.parent.mode===R?(k=this.advanceUntilMatched(a,a.type,J[a.type],h,h),this.ast.pushFlatten(k.reverse())):(this.ast=this.ast.parent,this.tokens.push(a));break;case r:case D:m=this.prevTokens[this.prevTokens.length-1],b=this.tokens[this.tokens.length-1];if(a.type===r&&b.type===q){this.tokens.push(a),this.ast=this.ast.parent;break}this.subParse(a,R),b=this.tokens[this.tokens.length-1];if(m&&m.type===c||b&&b.type===w)this.ast=this.ast.parent;break;case j:this.tokens.push(a),this.ast=this.ast.beget(Q);break;case E:b=this.tokens[this.tokens.length-1],b&&(b.type===w||b.type===x||b.type===p||b.type===E||this.ast.parent&&this.ast.parent.mode===R)?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;default:this.ast.parent&&this.ast.parent.mode!==R?(this.ast=this.ast.parent,this.tokens.push(a)):this.ast.push(a)}}};var T=S.prototype;T.insertDebugVars=function(a){this.options.debug&&this.buffer.push(this.options.helpersName+".vl = "+a.line+", ",this.options.helpersName+".vc = "+a.chr+"; \n")},T.visitMarkupTok=function(a,b,c){this.insertDebugVars(a),this.buffer.push("MKP("+a.val.replace(this.reEscapedQuote,"\\\\$1").replace(this.reQuote,"\\$1").replace(this.reLineBreak,"\\n")+")MKP")},T.visitBlockTok=function(a,b,c){this.buffer.push(a.val)},T.visitExpressionTok=function(a,b,c,d){var e="",f="",g=b.parent&&b.parent.mode!==R;this.options.htmlEscape!==!1&&(g&&c===0&&d&&(e+=this.options.helpersName+".escape("),g&&c===b.length-1&&d&&(f+=").toHtmlString()")),g&&c===0&&(this.insertDebugVars(a),e="__vbuffer.push("+e),g&&c===b.length-1&&(f+="); \n"),this.buffer.push(e+a.val+f),g&&c===b.length-1&&this.insertDebugVars(a)},T.visitNode=function(a){var b,d=a.slice(0),f,g,h;a.mode===R&&a.parent&&a.parent.mode!==R&&(f=a.filter(S.findNonExp).length);for(g=0;g<d.length;g++){h=d[g];if(h.type&&h.type===c||h.type===e)continue;h.vquery?this.visitNode(h):a.mode===P?this.visitMarkupTok(h,a,g):a.mode===Q?this.visitBlockTok(h,a,g):a.mode===R&&this.visitExpressionTok(h,a,g,f>0?!1:!0)}},T.escapeForDebug=function(a){return a.replace(this.reLineBreak,"!LB!").replace(this.reQuote,"\\$1").replace(this.reEscapedQuote,"\\$1")},T.replaceDevTokens=function(a){return a.replace(this.reHelpersName,this.options.helpersName).replace(this.reModelName,this.options.modelName)},T.addHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = HELPERSNAME.buffer; \n"+"HELPERSNAME.options = __vopts; \n"+"MODELNAME = MODELNAME || {}; \n"+(b.useWith?"with( MODELNAME ){ \n":"");c=this.replaceDevTokens(c);return c+a},T.addHelperHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = this.buffer; \n"+"var MODELNAME = this.model; \n"+"var HELPERSNAME = this; \n";c=this.replaceDevTokens(c);return c+a},T.addFoot=function(a){var b=this.options,c=""+(b.simple?'return HELPERSNAME.buffer.join(""); \n':"(__vopts && __vopts.onRenderEnd && __vopts.onRenderEnd(null, HELPERSNAME)); \nreturn (__vopts && __vopts.asContext) \n ? HELPERSNAME \n : HELPERSNAME.toString(); \n")+(b.useWith?"} \n":"")+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},T.addHelperFoot=function(a){var b=this.options,c=""+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},T.generate=function(){var a=this.options;this.buffer.length=0,this.visitNode(this.ast);var c=this.buffer.join("").split(")MKPMKP(").join("").split("MKP(").join("__vbuffer.push('").split(")MKP").join("'); \n");a.asHelper?(c=this.addHelperHead(c),c=this.addHelperFoot(c)):(c=this.addHead(c),c=this.addFoot(c)),a.debugCompiler&&(console.log(c),console.log(a)),this.cmpFunc=b.link(c,a);return this.cmpFunc},S.noop=function(){},S.findNonExp=function(a){return a.vquery&&a.mode===R?a.filter(S.findNonExp).length>0:a.vquery&&a.mode!==R?!0:!1},a.config={useWith:!1,modelName:"model",helpersName:"html",htmlEscape:!0,debug:!0,debugParser:!1,debugCompiler:!1,simple:!1,favorText:!1,externs:["window","document"],saveTextTag:!1,saveAT:!1},a.compile=function(b,c){if(b===""||typeof b!="string")throw new Error("Empty or non-string cannot be compiled");var d,e,f=[],g,h,i,j;c=M.extend({},a.config,c||{}),d=new L(b);while(e=d.advance())f.push(e);f.reverse(),g=new N(f,c),g.parse(),h=new S(g.ast,b,c),i=h.generate();return i};var U=Array.prototype.slice,V=/vash\.helpers\.([^= ]+?)\s*=\s*function([^(]*?)\(([^)]*?)\)\s*{/,W=/\}$/,X=/^\/\/\s*@\s*batch\s*=\s*(.*?)$/,Y=function(a,b,c,d){var e=b.split(/[\n\r]/g),f={},g=[],h="";e.forEach(function(b,e){var g=a.exec(b),i=g?c.apply(g,g):null;i&&(h=i,f[h]=[]),(!i||d)&&b&&f[h].push(b)}),Object.keys(f).forEach(function(a){f[a]=f[a].join("\n")});return f},Z=function(a,c,d){var e=a==="helper"?V:X,f=Y(e,c,function(a,b){return b.replace(/^\s+|\s+$/,"")},a==="helper"?!0:!1);f&&(Object.keys(f).forEach(function(c){f[c]=a==="helper"?$(f[c],d):b.compile("@{"+f[c]+"}",d)}),f.toClientString=function(){return Object.keys(f).reduce(function(a,b){return b==="toClientString"?a:a+f[b].toClientString()+"\n"},"")});return f},$=function(a,c){c=c||{};var d=a.replace(/^[\s\n\r]+|[\s\n\r]+$/,"").match(V),e=d[3].split(",").map(function(a){return a.replace(" ","")}),f=d[1],g=a.replace(V,"").replace(W,"");g="@{"+g+"}",c.args=e,c.asHelper=f;return b.compile(g,c)};a.compileHelper=Z.bind(null,"helper"),a.compileBatch=a.batch=Z.bind(null,"batch"),a.VLexer=L,a.VParser=N,a.VCompiler=S,a.vQuery=M,function(){function j(a,b){typeof b=="function"&&(b={onRenderEnd:b}),a&&a.onRenderEnd&&(b=b||{},b.onRenderEnd||(b.onRenderEnd=a.onRenderEnd),delete a.onRenderEnd),b||(b={});return b}b=typeof b=="undefined"?{}:b,b.compile||(typeof define=="function"&&define.amd?define(function(){return b}):typeof module=="object"&&module.exports?module.exports=b:window.vash=b);var a=b.helpers,c=function(a){this.buffer=new g,this.model=a,this.options=null,this.vl=0,this.vc=0};b.helpers=a=c.prototype={constructor:c,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer._vo.join("")};var d=/[&<>"'`]/g,e=function(a){return f[a]},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};a.raw=function(a){var b=function(){return a};a=a!=null?a:"";return{toHtmlString:b,toString:b}},a.escape=function(a){var b=function(){return a};a=a!=null?a:"";if(typeof a.toHtmlString!="function"){a=a.toString().replace(d,e);return{toHtmlString:b,toString:b}}return a};var g=function(){this._vo=[]};g.prototype.mark=function(a){var b=new h(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},g.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},g.prototype.spliceMark=function(a,b,c){var d=a.findInBuffer();if(d>-1){a.destroy(),arguments[0]=d;return this._vo.splice.apply(this._vo,arguments)}return[]},g.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},g.prototype.push=function(a){return this._vo.push(a)},g.prototype.pushConcat=function(a){var b;Array.isArray(a)?b=a:arguments.length>1?b=Array.prototype.slice.call(arguments):b=[a];for(var c=0;c<b.length;c++)this._vo.push(b[c]);return this.__vo},g.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.lastIndexOf=function(a){var b=this._vo.length;while(--b>=0)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},g.prototype.index=function(a){return this._vo[a]},g.prototype.flush=function(){return this.empty().join("")},g.prototype.toString=g.prototype.toHtmlString=function(){return this._vo.join("")};var h=b.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},i=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;h.uidLike=function(a){return(a||"").search(i)>-1},h.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},h.prototype.findInBuffer=function(){return this.destroyed?-1:this.markedIndex&&this.buffer.index(this.markedIndex)===this.uid?this.markedIndex:this.markedIndex=this.buffer.indexOf(this.uid)},a.constructor.reportError=function(a,b,c,d,e){e=e||"!LB!";var f=d.split(e),g=b===0&&c===0?f.length-1:3,h=Math.max(0,b-g),i=Math.min(f.length,b+g),j=f.slice(h,i).map(function(a,c,d){var e=c+h+1;return(e===b?" > ":" ")+(e<10?" ":"")+e+" | "+a}).join("\n");a.vashlineno=b,a.vashcharno=c,a.message="Problem while rendering template at line "+b+", character "+c+".\nOriginal message: "+a.message+"."+"\nContext: \n\n"+j+"\n\n";throw a},a.reportError=function(){this.constructor.reportError.apply(this,arguments)},b.link=function(d,e){var f,g;e.args||(e.args=[e.modelName,e.helpersName,"__vopts","vash"]);if(typeof d=="string"){f=d;try{g=e.args.slice(),g.push(d),d=Function.apply(null,g)}catch(h){a.reportError(h,0,0,f,/\n/)}}d.options={simple:e.simple,modelName:e.modelName,helpersName:e.helpersName};var i;e.asHelper?(d.options.args=e.args,d.options.asHelper=e.asHelper,i=function(){return d.apply(this,k.call(arguments))},a[e.asHelper]=i):i=function(a,f){if(e.simple){var g={buffer:[],escape:c.prototype.escape,raw:c.prototype.raw};return d(a,g,f,b)}f=j(a,f);return d(a,f&&f.context||new c(a),f,b)},i.toString=function(){return d.toString()},i._toString=function(){return Function.prototype.toString.call(i)},i.toClientString=function(){return"vash.link( "+d.toString()+", "+JSON.stringify(d.options)+" )"};return i};var k=Array.prototype.slice;b.lookup=function(a,c){var d=b.helpers.tplcache[a];if(!d)throw new Error("Could not find template: "+a);return c?d(c):d},b.install=function(a,c){var d=b.helpers.tplcache;if(typeof c=="string"){if(!b.compile)throw new Error("vash.install(path, [string]) is not available in the standalone runtime.");c=b.compile(c)}else if(typeof a=="object"){c=a,Object.keys(c).forEach(function(a){d[a]=c[a]});return d}return d[a]=c},b.uninstall=function(a){var c=b.helpers.tplcache,d=!1;if(typeof a=="string")return delete c[a];Object.keys(c).forEach(function(b){c[b]===a&&(d=delete c[b])});return d}}(),function(){var a=b.helpers;a.trim=function(a){return a.replace(/^\s*|\s*$/g,"")},a.config.highlighter=null,a.highlight=function(b,c){var d=this.buffer.mark();c();var e=this.buffer.fromMark(d);this.buffer.push("<pre><code>"),a.config.highlighter?this.buffer.push(a.config.highlighter(b,e.join("")).value):this.buffer.push(e),this.buffer.push("</code></pre>")}}(),function(){if(typeof window=="undefined")var a=require("fs"),c=require("path");var d=b.helpers;d.config.browser=!1,b.loadFile=function(e,f,g){f=M.extend({},b.config,f||{});var h=d.config.browser,i;!h&&f.settings&&f.settings.views&&(e=c.normalize(e),e.indexOf(c.normalize(f.settings.views))===-1&&(e=c.join(f.settings.views,e)),c.extname(e)||(e+="."+(f.settings["view engine"]||"vash")));try{i=f.cache||h?d.tplcache[e]||(d.tplcache[e]=b.compile(a.readFileSync(e,"utf8"))):b.compile(a.readFileSync(e,"utf8")),g&&g(null,i)}catch(j){g&&g(j,null)}},b.renderFile=function(a,c,d){b.loadFile(a,c,function(a,b){var e=c.onRenderEnd;d(a,!a&&b(c,function(a,b){b.finishLayout(),e&&e(a,b)}))})},d._ensureLayoutProps=function(){this.appends=this.appends||{},this.prepends=this.prepends||{},this.blocks=this.blocks||{},this.blockMarks=this.blockMarks||{}},d.finishLayout=function(){this._ensureLayoutProps();var a=this,b,c,d,e,f,g,h,i;for(b in this.blockMarks)c=this.blockMarks[b],e=this.prepends[b],d=this.blocks[b],f=this.appends[b],g=c.pop(),h=this.buffer.mark(),e&&e.forEach(function(b){a.buffer.pushConcat(b)}),block=d.pop(),block&&this.buffer.pushConcat(block),f&&f.forEach(function(b){a.buffer.pushConcat(b)}),i=this.buffer.fromMark(h).join(""),this.buffer.spliceMark(g,0,i);for(b in this.blockMarks)this.blockMarks[b].forEach(function(a){a.destroy()});delete this.blockMarks,delete this.prepends,delete this.blocks,delete this.appends;return this.toString()},d.extend=function(a,c){var d=this,e=this.buffer,f=this.model,g;this._ensureLayoutProps(),b.loadFile(a,this.model,function(a,b){var e=d.buffer.mark();c(d.model);var f=d.buffer.fromMark(e);d.isExtending=!0,b(d.model,{context:d}),d.isExtending=!1}),this.model=f},d.include=function(a,c){var d=this,e=this.buffer,f=this.model;b.loadFile(a,this.model,function(a,b){b(c||d.model,{context:d})}),this.model=f},d.block=function(a,b){this._ensureLayoutProps();var c=this,d=this.blockMarks[a]||(this.blockMarks[a]=[]),e=this.blocks[a]||(this.blocks[a]=[]),f,g;b&&(f=this.buffer.mark(),b(this.model),g=this.buffer.fromMark(f),g.length&&!this.isExtending&&e.push(g),g.length&&this.isExtending&&e.unshift(g)),d.push(this.buffer.mark("block-"+a))},d._handlePrependAppend=function(a,b,c){this._ensureLayoutProps();var d=this.buffer.mark(),e,f=this[a],g=f[b]||(f[b]=[]);c(this.model),e=this.buffer.fromMark(d),g.push(e)},d.append=function(a,b){this._handlePrependAppend("appends",a,b)},d.prepend=function(a,b){this._handlePrependAppend("prepends",a,b)}}(),a.__express=a.renderFile;return a}({version:"0.7.9-7"}))
*/void 0,function(a){typeof define=="function"&&define.amd?define(a):typeof module=="object"&&module.exports?module.exports=a:window.vash=a}(function(a){function R(a,b,c){this.ast=a,this.originalMarkup=b||"",this.options=c||{},this.reQuote=/(['"])/gi,this.reEscapedQuote=/\\+(["'])/gi,this.reLineBreak=/\r?\n/gi,this.reHelpersName=/HELPERSNAME/g,this.reModelName=/MODELNAME/g,this.reOriginalMarkup=/ORIGINALMARKUP/g,this.buffer=[]}function M(a,b){this.options=b||{},this.tokens=a,this.ast=L(N),this.prevTokens=[],this.inCommentLine=!1}function K(a){this.input=this.originalInput=a.replace(/^\uFEFF/,"").replace(/\r\n|\r/g,"\n"),this.lineno=1,this.charno=0}var b=a,c="AT",d="ASSIGN_OPERATOR",e="AT_COLON",f="AT_STAR_CLOSE",g="AT_STAR_OPEN",h="BACKSLASH",i="BRACE_CLOSE",j="BRACE_OPEN",k="CONTENT",l="DOUBLE_QUOTE",m="EMAIL",n="ESCAPED_QUOTE",o="FORWARD_SLASH",p="FUNCTION",q="HARD_PAREN_CLOSE",r="HARD_PAREN_OPEN",s="HTML_TAG_CLOSE",t="HTML_TAG_OPEN",u="HTML_TAG_VOID_CLOSE",v="IDENTIFIER",w="KEYWORD",x="LOGICAL",y="NEWLINE",z="NUMERIC_CONTENT",A="OPERATOR",B="PAREN_CLOSE",C="PAREN_OPEN",D="PERIOD",E="SINGLE_QUOTE",F="TEXT_TAG_CLOSE",G="TEXT_TAG_OPEN",H="WHITESPACE",I={};I[g]=f,I[j]=i,I[l]=l,I[r]=q,I[C]=B,I[E]=E,I[e]=y,I[o]=o;var J=[m,/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:ca|co\.uk|com|edu|net|org))\b/,g,/^(@\*)/,f,/^(\*@)/,e,/^(@\:)/,c,/^(@)/,C,/^(\()/,B,/^(\))/,r,/^(\[)/,q,/^(\])/,j,/^(\{)/,i,/^(\})/,G,/^(<text>)/,F,/^(<\/text>)/,t,function(){var a=/^(<[a-zA-Z@]+?[^>]*?["a-zA-Z]*>)/,b=/([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/,c=this.scan(a,t);c&&(this.spewIf(c,b),this.spewIf(c,/(@)/),this.spewIf(c,/(\/\s*>)/));return c},s,/^(<\/[^>@\b]+?>)/,u,/^(\/\s*>)/,D,/^(\.)/,y,function(){var a=this.scan(/^(\n)/,y);a&&(this.lineno++,this.charno=0);return a},H,/^(\s)/,p,/^(function)(?![\d\w])/,w,/^(case|catch|do|else|finally|for|function|goto|if|instanceof|return|switch|try|typeof|var|while|with)(?![\d\w])/,v,/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/,o,/^(\/)/,A,/^(===|!==|==|!==|>>>|<<|>>|>=|<=|>|<|\+|-|\/|\*|\^|%|\:|\?)/,d,/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=|=)/,x,/^(&&|\|\||&|\||\^)/,n,/^(\\+['"])/,h,/^(\\)/,l,/^(\")/,E,/^(\')/,z,/^([0-9]+)/,k,/^([^\s})@.]+?)/];K.prototype={scan:function(a,b){var c,d;if(c=a.exec(this.input)){this.input=this.input.substr(c[1].length),d={type:b,line:this.lineno,chr:this.charno,val:c[1]||"",toString:function(){return"["+this.type+" ("+this.line+","+this.chr+"): "+this.val+"]"}},this.charno+=c[0].length;return d}},spewIf:function(a,b){var c,d,e;a&&(c=b.exec(a.val),c&&(d=a.val.indexOf(c[1]),e=a.val.substring(d),this.input=e+this.input,this.charno-=e.length,a.val=a.val.substring(0,d)));return a},advance:function(){var a,b,c,d;for(a=0;a<J.length;a+=2){c=J[a+1],c.displayName=J[a],typeof c=="function"&&(d=c.call(this)),typeof c.exec=="function"&&(d=this.scan(c,J[a]));if(d)return d}}};var L=function(a){return new L.fn.init(a)};L.prototype.init=function(a){typeof a=="string"&&(this.mode=a),this.maxCheck()},L.fn=L.prototype.init.prototype=L.prototype,L.fn.vquery="yep",L.fn.constructor=L,L.fn.length=0,L.fn.parent=null,L.fn.mode=null,L.fn.tagName=null,L.fn.beget=function(a,b){var c=L(a);c.parent=this,this.push(c),b&&(c.tagName=b),this.maxCheck();return c},L.fn.closest=function(a,b){var c=this;while(c)if(c.tagName!==b&&c.parent)c=c.parent;else break;return c},L.fn.pushFlatten=function(a){var b=a,c,d;while(b.length===1&&b[0].vquery)b=b[0];if(b.mode!==N)this.push(b);else for(c=0;c<b.length;c++)this.push(b[c]);this.maxCheck();return this},L.fn.push=function(a){L.isArray(a)?(a.vquery&&a.forEach(function(a){a.parent=this},this),Array.prototype.push.apply(this,a)):(a.vquery&&(a.parent=this),Array.prototype.push.call(this,a)),this.maxCheck();return this.length},L.fn.root=function(){var a=this;while(a&&a.parent&&(a=a.parent));return a},L.fn.toTreeString=function(){function c(d){var e,f;a.push(Array(b).join(" |")+" +"+d.mode+" "+(d.tagName||"")),b+=1,e=d.slice();while(f=e.shift())f.vquery===L.fn.vquery?c(f):a.push(Array(b).join(" |")+" "+(f?f.toString().replace(/(\r|\n)/g,""):"[empty]"));b-=1,a.push(Array(b).join(" |")+" -"+d.mode+" "+(d.tagName||""))}var a=[],b=1;c(this);return a.join("\n")},L.fn.maxCheck=function(a){if(this.length>=L.maxSize){var b=new Error;b.message="Maximum number of elements exceeded.\nThis is typically caused by an unmatched character or tag. Parse tree follows:\n"+this.toTreeString(),b.name="vQueryDepthException";throw b}},L.maxSize=1e5,L.fn.flatten=function(){var a;return this.reduce(function b(c,d,e,f){if(d.vquery){c.push({type:"META",val:"START"+d.mode,tagName:d.tagName}),a=d.reduce(b,c),a.push({type:"META",val:"END"+d.mode,tagName:d.tagName});return a}d.mode=f.mode,c.push(d);return c},[])},L.reconstitute=function(a){return a.reduce(function b(a,b,c,d){b.type==="META"?a=a.parent:(b.mode!==a.mode&&(a=a.beget(b.mode,b.tagName)),a.push(b));return a},L(N))},L.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"},L.extend=function(a){var b,c,d;for(c=1;c<arguments.length;c++){b=arguments[c];for(d in b)a[d]=b[d]}return a},L.takeMethodsFromArray=function(){var a=["pop","push","reverse","shift","sort","splice","unshift","concat","join","slice","indexOf","lastIndexOf","filter","forEach","every","map","some","reduce","reduceRight"],b=[],c;for(var d=0;d<a.length;d++){c=a[d];if(typeof b[c]=="function")L.fn[c]||function(a){L.fn[a]=function(){return b[a].apply(this,Array.prototype.slice.call(arguments,0))}}(c);else throw new Error("Vash requires ES5 array iteration methods, missing: "+c)}},L.takeMethodsFromArray();var N="PROGRAM",O="MARKUP",P="BLOCK",Q="EXPRESSION";M.prototype={parse:function(){var a,b,c,d;while(this.prevTokens.push(a),a=this.tokens.pop()){this.options.debugParser&&console.log(this.ast&&this.ast.mode,a.type,a.toString(),a.val);if(this.ast.mode===N||this.ast.mode===null)this.ast=this.ast.beget(this.options.initialMode||O),this.options.initialMode===Q&&(this.ast=this.ast.beget(Q));if(this.ast.mode===O){this.handleMKP(a);continue}if(this.ast.mode===P){this.handleBLK(a);continue}if(this.ast.mode===Q){this.handleEXP(a);continue}}this.ast=this.ast.root(),this.options.debugParser&&!this.options.initialMode&&(console.log(this.ast.toString()),console.log(this.ast.toTreeString()));return this.ast},exceptionFactory:function(a,b,c){b=="UNMATCHED"&&(a.name="UnmatchedCharacterError",this.ast=this.ast.root(),c&&(a.message="Unmatched "+c.type+" at line "+c.line+", character "+c.chr+". Value: "+c.val+"\n "+this.ast.toTreeString(),a.lineNumber=c.line));return a},advanceUntilNot:function(a){var b,c,d=[];while(c=this.tokens[this.tokens.length-1])if(c.type===a)b=this.tokens.pop(),d.push(b);else break;return d},advanceUntilMatched:function(a,b,c,d,e){var f=a,g=null,h=0,i=0,j=[];while(f){f.type===b?g&&g.type!==d&&b!==c||!g?h++:b===c&&g.type!==d&&i++:f.type===c&&(i++,g&&g.type===e&&i--),j.push(f);if(h===i)break;g=f,f=this.tokens.pop();if(!f)throw this.exceptionFactory(new Error,"UNMATCHED",a)}return j.reverse()},subParse:function(a,b,d){var e,f,g,h=L.extend({},this.options);h.initialMode=b,e=this.advanceUntilMatched(a,a.type,I[a.type],null,c),e.pop(),f=e.shift(),d||this.ast.push(a),g=new M(e,h),g.parse(),d&&(g.ast[0].unshift(a),g.ast[0].push(f)),this.ast.pushFlatten(g.ast),d||this.ast.push(f)},handleMKP:function(a){var b=this.tokens[this.tokens.length-1],d=this.tokens[this.tokens.length-2],i=null,k;switch(a.type){case g:this.advanceUntilMatched(a,g,f,c,c);break;case c:if(b){this.options.saveAT&&this.ast.push(a);switch(b.type){case C:case v:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(Q);break;case w:case p:case j:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(P);break;case c:case e:b.type="CONTENT",this.ast.push(this.tokens.pop());break;default:this.ast.push(this.tokens.pop())}}break;case G:case t:i=a.val.match(/^<([^\/ >]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),this.ast.tagName?this.ast=this.ast.beget(O,i[1]):this.ast.tagName=i[1],(t===a.type||this.options.saveTextTag)&&this.ast.push(a);break;case F:case s:i=a.val.match(/^<\/([^>]+)/i),i===null&&b&&b.type===c&&d&&(i=d.val.match(/(.*)/)),k=this.ast.closest(O,i[1]),k!==null&&k.tagName===i[1]&&(this.ast=k),(s===a.type||this.options.saveTextTag)&&this.ast.push(a),this.ast.parent&&this.ast.parent.mode===P&&(this.ast=this.ast.parent);break;case u:this.ast.push(a),this.ast=this.ast.parent;break;case h:a.val+="\\",this.ast.push(a);break;default:this.ast.push(a)}},handleBLK:function(a){var b=this.tokens[this.tokens.length-1],d,i,m,n,q,r,u;switch(a.type){case c:b.type!==c&&!this.inCommentLine?(this.tokens.push(a),this.ast=this.ast.beget(O)):(b.type=k,this.ast.push(b),this.tokens.pop());break;case g:this.advanceUntilMatched(a,g,f,c,c);break;case e:this.subParse(a,O,!0);break;case G:case F:case t:case s:this.ast=this.ast.beget(O),this.tokens.push(a);break;case o:case E:case l:a.type===o&&b&&b.type===o&&(this.inCommentLine=!0),this.inCommentLine?this.ast.push(a):(n=this.advanceUntilMatched(a,a.type,I[a.type],h,h).map(function(a){a.type===c&&(a.type=k);return a}),this.ast.pushFlatten(n.reverse()));break;case y:this.inCommentLine&&(this.inCommentLine=!1),this.ast.push(a);break;case j:case C:d=this.options.favorText&&a.type===j?O:P,this.subParse(a,d),n=this.advanceUntilNot(H),b=this.tokens[this.tokens.length-1],b&&b.type!==w&&b.type!==p&&b.type!==j&&a.type!==C?(this.tokens.push.apply(this.tokens,n.reverse()),this.ast=this.ast.parent):this.ast.push(n);break;default:this.ast.push(a)}},handleEXP:function(a){var b=null,e,f,g,i,k,m,n;switch(a.type){case w:case p:this.ast=this.ast.beget(P),this.tokens.push(a);break;case H:case x:case d:case A:case z:this.ast.parent&&this.ast.parent.mode===Q?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;case v:this.ast.push(a);break;case E:case l:this.ast.parent&&this.ast.parent.mode===Q?(k=this.advanceUntilMatched(a,a.type,I[a.type],h,h),this.ast.pushFlatten(k.reverse())):(this.ast=this.ast.parent,this.tokens.push(a));break;case r:case C:m=this.prevTokens[this.prevTokens.length-1],b=this.tokens[this.tokens.length-1];if(a.type===r&&b.type===q){this.tokens.push(a),this.ast=this.ast.parent;break}this.subParse(a,Q),b=this.tokens[this.tokens.length-1];if(m&&m.type===c||b&&b.type===v)this.ast=this.ast.parent;break;case j:this.tokens.push(a),this.ast=this.ast.beget(P);break;case D:b=this.tokens[this.tokens.length-1],b&&(b.type===v||b.type===w||b.type===p||b.type===D||this.ast.parent&&this.ast.parent.mode===Q)?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;default:this.ast.parent&&this.ast.parent.mode!==Q?(this.ast=this.ast.parent,this.tokens.push(a)):this.ast.push(a)}}};var S=R.prototype;S.insertDebugVars=function(a){this.options.debug&&this.buffer.push(this.options.helpersName+".vl = "+a.line+", ",this.options.helpersName+".vc = "+a.chr+"; \n")},S.visitMarkupTok=function(a,b,c){this.insertDebugVars(a),this.buffer.push("MKP("+a.val.replace(this.reEscapedQuote,"\\\\$1").replace(this.reQuote,"\\$1").replace(this.reLineBreak,"\\n")+")MKP")},S.visitBlockTok=function(a,b,c){this.buffer.push(a.val)},S.visitExpressionTok=function(a,b,c,d){var e="",f="",g=b.parent&&b.parent.mode!==Q;this.options.htmlEscape!==!1&&(g&&c===0&&d&&(e+=this.options.helpersName+".escape("),g&&c===b.length-1&&d&&(f+=").toHtmlString()")),g&&c===0&&(this.insertDebugVars(a),e="__vbuffer.push("+e),g&&c===b.length-1&&(f+="); \n"),this.buffer.push(e+a.val+f),g&&c===b.length-1&&this.insertDebugVars(a)},S.visitNode=function(a){var b,d=a.slice(0),f,g,h;a.mode===Q&&a.parent&&a.parent.mode!==Q&&(f=a.filter(R.findNonExp).length);for(g=0;g<d.length;g++){h=d[g];if(h.type&&h.type===c||h.type===e)continue;h.vquery?this.visitNode(h):a.mode===O?this.visitMarkupTok(h,a,g):a.mode===P?this.visitBlockTok(h,a,g):a.mode===Q&&this.visitExpressionTok(h,a,g,f>0?!1:!0)}},S.escapeForDebug=function(a){return a.replace(this.reLineBreak,"!LB!").replace(this.reQuote,"\\$1").replace(this.reEscapedQuote,"\\$1")},S.replaceDevTokens=function(a){return a.replace(this.reHelpersName,this.options.helpersName).replace(this.reModelName,this.options.modelName)},S.addHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = HELPERSNAME.buffer; \n"+"HELPERSNAME.options = __vopts; \n"+"MODELNAME = MODELNAME || {}; \n"+(b.useWith?"with( MODELNAME ){ \n":"");c=this.replaceDevTokens(c);return c+a},S.addHelperHead=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = this.buffer; \n"+"var MODELNAME = this.model; \n"+"var HELPERSNAME = this; \n";c=this.replaceDevTokens(c);return c+a},S.addFoot=function(a){var b=this.options,c=""+(b.simple?'return HELPERSNAME.buffer.join(""); \n':"(__vopts && __vopts.onRenderEnd && __vopts.onRenderEnd(null, HELPERSNAME)); \nreturn (__vopts && __vopts.asContext) \n ? HELPERSNAME \n : HELPERSNAME.toString(); \n")+(b.useWith?"} \n":"")+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},S.addHelperFoot=function(a){var b=this.options,c=""+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"");c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return a+c},S.generate=function(){var a=this.options;this.buffer.length=0,this.visitNode(this.ast);var c=this.buffer.join("").split(")MKPMKP(").join("").split("MKP(").join("__vbuffer.push('").split(")MKP").join("'); \n");a.asHelper?(c=this.addHelperHead(c),c=this.addHelperFoot(c)):(c=this.addHead(c),c=this.addFoot(c)),a.debugCompiler&&(console.log(c),console.log(a)),this.cmpFunc=b.link(c,a);return this.cmpFunc},R.noop=function(){},R.findNonExp=function(a){return a.vquery&&a.mode===Q?a.filter(R.findNonExp).length>0:a.vquery&&a.mode!==Q?!0:!1},a.config={useWith:!1,modelName:"model",helpersName:"html",htmlEscape:!0,debug:!0,debugParser:!1,debugCompiler:!1,simple:!1,favorText:!1,externs:["window","document"],saveTextTag:!1,saveAT:!1},a.compile=function(b,c){if(b===""||typeof b!="string")throw new Error("Empty or non-string cannot be compiled");var d,e,f=[],g,h,i,j;c=L.extend({},a.config,c||{}),d=new K(b);while(e=d.advance())f.push(e);f.reverse(),g=new M(f,c),g.parse(),h=new R(g.ast,b,c),i=h.generate();return i};var T=Array.prototype.slice,U=/vash\.helpers\.([^= ]+?)\s*=\s*function([^(]*?)\(([^)]*?)\)\s*{/,V=/\}$/,W=/^\/\/\s*@\s*batch\s*=\s*(.*?)$/,X=function(a,b,c,d){var e=b.split(/[\n\r]/g),f={},g=[],h="";e.forEach(function(b,e){var g=a.exec(b),i=g?c.apply(g,g):null;i&&(h=i,f[h]=[]),(!i||d)&&b&&f[h].push(b)}),Object.keys(f).forEach(function(a){f[a]=f[a].join("\n")});return f},Y=function(a,c,d){var e=a==="helper"?U:W,f=X(e,c,function(a,b){return b.replace(/^\s+|\s+$/,"")},a==="helper"?!0:!1);f&&(Object.keys(f).forEach(function(c){f[c]=a==="helper"?Z(f[c],d):b.compile("@{"+f[c]+"}",d)}),f.toClientString=function(){return Object.keys(f).reduce(function(a,b){return b==="toClientString"?a:a+f[b].toClientString()+"\n"},"")});return f},Z=function(a,c){c=c||{};var d=a.replace(/^[\s\n\r]+|[\s\n\r]+$/,"").match(U),e=d[3].split(",").map(function(a){return a.replace(" ","")}),f=d[1],g=a.replace(U,"").replace(V,"");g="@{"+g+"}",c.args=e,c.asHelper=f;return b.compile(g,c)};a.compileHelper=Y.bind(null,"helper"),a.compileBatch=a.batch=Y.bind(null,"batch"),a.VLexer=K,a.VParser=M,a.VCompiler=R,a.vQuery=L,function(){function j(a,b){typeof b=="function"&&(b={onRenderEnd:b}),a&&a.onRenderEnd&&(b=b||{},b.onRenderEnd||(b.onRenderEnd=a.onRenderEnd),delete a.onRenderEnd),b||(b={});return b}b=typeof b=="undefined"?{}:b,b.compile||(typeof define=="function"&&define.amd?define(function(){return b}):typeof module=="object"&&module.exports?module.exports=b:window.vash=b);var a=b.helpers,c=function(a){this.buffer=new g,this.model=a,this.options=null,this.vl=0,this.vc=0};b.helpers=a=c.prototype={constructor:c,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer._vo.join("")};var d=/[&<>"'`]/g,e=function(a){return f[a]},f={"&":"&amp;","<":"&lt;",">":"&gt;",'"':"&quot;","'":"&#x27;","`":"&#x60;"};a.raw=function(a){var b=function(){return a};a=a!=null?a:"";return{toHtmlString:b,toString:b}},a.escape=function(a){var b=function(){return a};a=a!=null?a:"";if(typeof a.toHtmlString!="function"){a=a.toString().replace(d,e);return{toHtmlString:b,toString:b}}return a};var g=function(){this._vo=[]};g.prototype.mark=function(a){var b=new h(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},g.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},g.prototype.spliceMark=function(a,b,c){var d=a.findInBuffer();if(d>-1){a.destroy(),arguments[0]=d;return this._vo.splice.apply(this._vo,arguments)}return[]},g.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},g.prototype.push=function(a){return this._vo.push(a)},g.prototype.pushConcat=function(a){var b;Array.isArray(a)?b=a:arguments.length>1?b=Array.prototype.slice.call(arguments):b=[a];for(var c=0;c<b.length;c++)this._vo.push(b[c]);return this.__vo},g.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.lastIndexOf=function(a){var b=this._vo.length;while(--b>=0)if(a.test&&this._vo[b].search(a)>-1||this._vo[b]==a)return b;return-1},g.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},g.prototype.index=function(a){return this._vo[a]},g.prototype.flush=function(){return this.empty().join("")},g.prototype.toString=g.prototype.toHtmlString=function(){return this._vo.join("")};var h=b.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},i=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;h.uidLike=function(a){return(a||"").search(i)>-1},h.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},h.prototype.findInBuffer=function(){return this.destroyed?-1:this.markedIndex&&this.buffer.index(this.markedIndex)===this.uid?this.markedIndex:this.markedIndex=this.buffer.indexOf(this.uid)},a.constructor.reportError=function(a,b,c,d,e){e=e||"!LB!";var f=d.split(e),g=b===0&&c===0?f.length-1:3,h=Math.max(0,b-g),i=Math.min(f.length,b+g),j=f.slice(h,i).map(function(a,c,d){var e=c+h+1;return(e===b?" > ":" ")+(e<10?" ":"")+e+" | "+a}).join("\n");a.vashlineno=b,a.vashcharno=c,a.message="Problem while rendering template at line "+b+", character "+c+".\nOriginal message: "+a.message+"."+"\nContext: \n\n"+j+"\n\n";throw a},a.reportError=function(){this.constructor.reportError.apply(this,arguments)},b.link=function(d,e){var f,g;e.args||(e.args=[e.modelName,e.helpersName,"__vopts","vash"]);if(typeof d=="string"){f=d;try{g=e.args.slice(),g.push(d),d=Function.apply(null,g)}catch(h){a.reportError(h,0,0,f,/\n/)}}d.options={simple:e.simple,modelName:e.modelName,helpersName:e.helpersName};var i;e.asHelper?(d.options.args=e.args,d.options.asHelper=e.asHelper,i=function(){return d.apply(this,k.call(arguments))},a[e.asHelper]=i):i=function(a,f){if(e.simple){var g={buffer:[],escape:c.prototype.escape,raw:c.prototype.raw};return d(a,g,f,b)}f=j(a,f);return d(a,f&&f.context||new c(a),f,b)},i.toString=function(){return d.toString()},i._toString=function(){return Function.prototype.toString.call(i)},i.toClientString=function(){return"vash.link( "+d.toString()+", "+JSON.stringify(d.options)+" )"};return i};var k=Array.prototype.slice;b.lookup=function(a,c){var d=b.helpers.tplcache[a];if(!d)throw new Error("Could not find template: "+a);return c?d(c):d},b.install=function(a,c){var d=b.helpers.tplcache;if(typeof c=="string"){if(!b.compile)throw new Error("vash.install(path, [string]) is not available in the standalone runtime.");c=b.compile(c)}else if(typeof a=="object"){c=a,Object.keys(c).forEach(function(a){d[a]=c[a]});return d}return d[a]=c},b.uninstall=function(a){var c=b.helpers.tplcache,d=!1;if(typeof a=="string")return delete c[a];Object.keys(c).forEach(function(b){c[b]===a&&(d=delete c[b])});return d}}(),function(){var a=b.helpers;a.trim=function(a){return a.replace(/^\s*|\s*$/g,"")},a.config.highlighter=null,a.highlight=function(b,c){var d=this.buffer.mark();c();var e=this.buffer.fromMark(d);this.buffer.push("<pre><code>"),a.config.highlighter?this.buffer.push(a.config.highlighter(b,e.join("")).value):this.buffer.push(e),this.buffer.push("</code></pre>")}}(),function(){if(typeof window=="undefined")var a=require("fs"),c=require("path");var d=b.helpers;d.config.browser=!1,b.loadFile=function(e,f,g){f=L.extend({},b.config,f||{});var h=d.config.browser,i;!h&&f.settings&&f.settings.views&&(e=c.normalize(e),e.indexOf(c.normalize(f.settings.views))===-1&&(e=c.join(f.settings.views,e)),c.extname(e)||(e+="."+(f.settings["view engine"]||"vash")));try{i=f.cache||h?d.tplcache[e]||(d.tplcache[e]=b.compile(a.readFileSync(e,"utf8"))):b.compile(a.readFileSync(e,"utf8")),g&&g(null,i)}catch(j){g&&g(j,null)}},b.renderFile=function(a,c,d){b.loadFile(a,c,function(a,b){var e=c.onRenderEnd;d(a,!a&&b(c,function(a,b){b.finishLayout(),e&&e(a,b)}))})},d._ensureLayoutProps=function(){this.appends=this.appends||{},this.prepends=this.prepends||{},this.blocks=this.blocks||{},this.blockMarks=this.blockMarks||{}},d.finishLayout=function(){this._ensureLayoutProps();var a=this,b,c,d,e,f,g,h,i;for(b in this.blockMarks)c=this.blockMarks[b],e=this.prepends[b],d=this.blocks[b],f=this.appends[b],g=c.pop(),h=this.buffer.mark(),e&&e.forEach(function(b){a.buffer.pushConcat(b)}),block=d.pop(),block&&this.buffer.pushConcat(block),f&&f.forEach(function(b){a.buffer.pushConcat(b)}),i=this.buffer.fromMark(h).join(""),this.buffer.spliceMark(g,0,i);for(b in this.blockMarks)this.blockMarks[b].forEach(function(a){a.destroy()});delete this.blockMarks,delete this.prepends,delete this.blocks,delete this.appends;return this.toString()},d.extend=function(a,c){var d=this,e=this.buffer,f=this.model,g;this._ensureLayoutProps(),b.loadFile(a,this.model,function(a,b){var e=d.buffer.mark();c(d.model);var f=d.buffer.fromMark(e);d.isExtending=!0,b(d.model,{context:d}),d.isExtending=!1}),this.model=f},d.include=function(a,c){var d=this,e=this.buffer,f=this.model;b.loadFile(a,this.model,function(a,b){b(c||d.model,{context:d})}),this.model=f},d.block=function(a,b){this._ensureLayoutProps();var c=this,d=this.blockMarks[a]||(this.blockMarks[a]=[]),e=this.blocks[a]||(this.blocks[a]=[]),f,g;b&&(f=this.buffer.mark(),b(this.model),g=this.buffer.fromMark(f),g.length&&!this.isExtending&&e.push(g),g.length&&this.isExtending&&e.unshift(g)),d.push(this.buffer.mark("block-"+a))},d._handlePrependAppend=function(a,b,c){this._ensureLayoutProps();var d=this.buffer.mark(),e,f=this[a],g=f[b]||(f[b]=[]);c(this.model),e=this.buffer.fromMark(d),g.push(e)},d.append=function(a,b){this._handlePrependAppend("appends",a,b)},d.prepend=function(a,b){this._handlePrependAppend("prepends",a,b)}}(),a.__express=a.renderFile;return a}({version:"0.7.10-2"}))
{
"name": "vash",
"description": "Razor syntax for JS templating",
"version": "0.7.9-7",
"version": "0.7.10-2",
"author": "Andrew Petersen <senofpeter@gmail.com>",

@@ -6,0 +6,0 @@ "homepage": "https://github.com/kirbysayshi/vash",

@@ -25,3 +25,2 @@ /*jshint strict:false, asi:true, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

vQuery.fn.tagName = null;
vQuery.fn.tagVoid = null;

@@ -28,0 +27,0 @@ vQuery.fn.beget = function(mode, tagName){

@@ -22,3 +22,2 @@ /*jshint strict:false, asi:true, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

,HTML_TAG_OPEN = 'HTML_TAG_OPEN'
,HTML_TAG_VOID_OPEN = 'HTML_TAG_VOID_OPEN'
,HTML_TAG_VOID_CLOSE = 'HTML_TAG_VOID_CLOSE'

@@ -112,6 +111,4 @@ ,IDENTIFIER = 'IDENTIFIER'

,reEmail = /([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/
,reSelfClosing = /^(<[a-zA-Z@]+(?:\s+\S+)*\s*\/>)/
var tok = this.scan( reSelfClosing, HTML_TAG_VOID_OPEN )
|| this.scan( reHtml, HTML_TAG_OPEN );
var tok = this.scan( reHtml, HTML_TAG_OPEN );

@@ -118,0 +115,0 @@ if( tok ){

@@ -239,3 +239,2 @@ /*jshint strict:false, asi:true, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

case HTML_TAG_OPEN:
case HTML_TAG_VOID_OPEN:
tagName = curr.val.match(/^<([^\/ >]+)/i);

@@ -254,11 +253,4 @@

// mark this ast as void, to enable recognition of HTML_TAG_VOID_CLOSE,
// which is otherwise generic
if(curr.type === HTML_TAG_VOID_OPEN){
this.ast.tagVoid = this.ast.tagName;
}
if(
HTML_TAG_VOID_OPEN === curr.type
|| HTML_TAG_OPEN === curr.type
HTML_TAG_OPEN === curr.type
|| this.options.saveTextTag

@@ -302,12 +294,4 @@ ){

case HTML_TAG_VOID_CLOSE:
// this should only be a valid token if tagVoid is defined, meaning
// HTML_TAG_VOID_OPEN was previously found within this markup block
if(this.ast.tagVoid){
this.ast.push(curr);
this.ast = this.ast.parent;
} else {
this.tokens.push(curr); // defer
}
this.ast.push(curr);
this.ast = this.ast.parent;
break;

@@ -364,3 +348,2 @@

case TEXT_TAG_CLOSE:
case HTML_TAG_VOID_OPEN:
case HTML_TAG_OPEN:

@@ -367,0 +350,0 @@ case HTML_TAG_CLOSE:

@@ -789,2 +789,14 @@ var vows = require('vows')

,'self-closing tag does not grab too much': {
topic: '@{{<b ></b>}<img />}'
,'when preceeded by tag with whitespace': function(topic) {
var tpl = vash.compile(topic)
, expected = '<b ></b><img />'
assert.equal(tpl(), expected);
}
}
,'markup with numbers': {

@@ -1916,3 +1928,3 @@ topic: function(){

assert.equal( flattened[openIdx].type, 'HTML_TAG_OPEN' );
assert.equal( flattened[openIdx+2].type, 'HTML_TAG_VOID_OPEN' );
assert.equal( flattened[openIdx+2].type, 'HTML_TAG_OPEN' );
assert.equal( flattened[openIdx+3].type, 'HTML_TAG_VOID_CLOSE' );

@@ -1919,0 +1931,0 @@ assert.equal( flattened[openIdx+5].type, 'HTML_TAG_CLOSE' );

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc