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.5.14-1803 to 0.5.15-1896

test/echo.js

174

build/vash-runtime-all.js
/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

@@ -15,28 +15,27 @@ * https://github.com/kirbysayshi/vash

if(!vash.compile && typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(!vash.compile && typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else if(!vash.compile){
window['vash'] = vash; // BROWSER
// only fully define if this is standalone
if(!vash.compile){
if(typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else {
window['vash'] = vash; // BROWSER
}
}
var helpers = vash['helpers']
,Helpers
,Buffer;
var helpers = vash['helpers'];
if ( !helpers ) {
Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
var Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
this.vl = 0;
this.vc = 0;
};
this.vl = 0;
this.vc = 0;
};
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}};
}
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}, tplcache: {} };

@@ -63,5 +62,2 @@ // this allows a template to return the context, and coercion

// raw: explicitly prevent an expression or value from being HTML escaped.
helpers.raw = function( val ) {

@@ -106,3 +102,3 @@ var func = function() { return val; };

Buffer = function() {
var Buffer = function() {
this._vo = [];

@@ -161,3 +157,3 @@ }

if( this._vo[i] == str ){
return i;
return i;
}

@@ -241,8 +237,59 @@ }

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
lb = lb || '!LB!';
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
// ERROR REPORTING
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// VASH.LINK
// Reconstitute precompiled functions
vash['link'] = function( cmpFunc, Helpers ){
Helpers = Helpers || vash.helpers.constructor;
vash['link'] = function( cmpFunc, modelName, helpersName ){
var joined;
if( typeof cmpFunc === 'string' ){
joined = cmpFunc;
try {
cmpFunc = new Function(modelName, helpersName, '__vopts', 'vash', joined);
} catch(e){
helpers.reportError(e, 0, 0, joined, /\n/);
}
}
// need this to enable `vash.batch` to reconstitute
cmpFunc.options = { modelName: modelName, helpersName: helpersName };
var linked = function( model, opts ){

@@ -266,15 +313,15 @@

return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts );
}
return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts, vash );
};
linked.toString = function(){
return cmpFunc.toString();
}
};
linked.toClientString = function(){
return 'vash.link( ' + cmpFunc.toString() + ' )';
}
return 'vash.link( ' + cmpFunc.toString() + ', "' + modelName + '", "' + helpersName + '" )';
};
return linked;
}
};

@@ -285,35 +332,34 @@ // VASH.LINK

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// TPL CACHE
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
vash.lookup = function( path, model ){
var tpl = vash.helpers.tplcache[path];
if( !tpl ){ throw new Error('Could not find template: ' + path); }
if( model ){ return tpl(model); }
else return tpl;
};
lb = lb || '!LB!';
vash.install = function( path, tpl ){
var cache = vash.helpers.tplcache;
if( typeof tpl === 'string' ){
if( !vash.compile ){ throw new Error('vash.install(path, [string]) is not available in the standalone runtime.') }
tpl = vash.compile(tpl);
}
return cache[path] = tpl;
};
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
vash.uninstall = function( path ){
var cache = vash.helpers.tplcache
,deleted = false;
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
if( typeof path === 'string' ){
return delete cache[path];
} else {
Object.keys(cache).forEach(function(key){
if( cache[key] === path ){ deleted = delete cache[key]; }
})
return deleted;
}
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
}());

@@ -382,4 +428,2 @@

helpers.tplcache = {};
vash.loadFile = function(filepath, options, cb){

@@ -420,3 +464,2 @@

filepath = path.join( options.settings.views, filepath );
}

@@ -430,3 +473,2 @@

try {
// if browser, tpl must exist in tpl cache

@@ -433,0 +475,0 @@ tpl = options.cache || browser

/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

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

(function(){vash=typeof vash=="undefined"?{}:vash,!vash.compile&&typeof define=="function"&&define.amd?define(function(){return vash}):!vash.compile&&typeof module=="object"&&module.exports?module.exports=vash:vash.compile||(window.vash=vash);var a=vash.helpers,b,c;a||(b=function(a){this.buffer=new c,this.model=a,this.vl=0,this.vc=0},vash.helpers=a=b.prototype={constructor:b,config:{}}),a.toString=a.toHtmlString=function(){return this.buffer.toString()};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},c=function(){this._vo=[]},c.prototype.mark=function(a){var b=new g(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},c.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},c.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[]},c.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},c.prototype.push=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},c.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(this._vo[b]==a)return b;return-1},c.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},c.prototype.index=function(a){return this._vo[a]},c.prototype.flush=function(){return this.empty().join("")},c.prototype.toString=c.prototype.toHtmlString=function(){return this._vo.join("")};var g=vash.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},h=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;g.uidLike=function(a){return(a||"").search(h)>-1},g.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},g.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)},vash.link=function(a,b){b=b||vash.helpers.constructor;var c=function(c,d){typeof d=="function"&&(d={onRenderEnd:d}),d=d||{},c&&c.onRenderEnd&&d&&!d.onRenderEnd&&(d.onRenderEnd=c.onRenderEnd),c&&c.onRenderEnd&&delete c.onRenderEnd;return a(c,d&&d.context||new b(c),d)};c.toString=function(){return a.toString()},c.toClientString=function(){return"vash.link( "+a.toString()+" )"};return c},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.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)}})(),function(){var a=vash.helpers;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"),b=require("path");var c=vash.helpers;c.config.browser=!1,c.tplcache={},vash.loadFile=function(d,e,f){e=vQuery.extend({},vash.config,e||{});var g=c.config.browser,h;!g&&e.settings&&e.settings.views&&(d=b.normalize(d),d.indexOf(b.normalize(e.settings.views))===-1&&(d=b.join(e.settings.views,d)),b.extname(d)||(d+="."+(e.settings["view engine"]||"vash")));try{h=e.cache||g?c.tplcache[d]||(c.tplcache[d]=vash.compile(a.readFileSync(d,"utf8"))):vash.compile(a.readFileSync(d,"utf8")),f&&f(null,h)}catch(i){f&&f(i,null)}},vash.renderFile=function(a,b,c){vash.loadFile(a,b,function(a,d){var e=b.onRenderEnd;c(a,d(b,function(a,b){b.finishLayout(),e&&e(a,b)}))})},c._ensureLayoutProps=function(){this.appends=this.appends||{},this.prepends=this.prepends||{},this.blocks=this.blocks||{},this.blockMarks=this.blockMarks||{}},c.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.push(b)}),block=d.pop(),block&&this.buffer.push(block),f&&f.forEach(function(b){a.buffer.push(b)}),i=this.buffer.fromMark(h),i.unshift(g,0),this.buffer.spliceMark.apply(this.buffer,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()},c.extend=function(a,b){var c=this,d=this.buffer,e=this.model,f;this._ensureLayoutProps(),vash.loadFile(a,this.model,function(a,d){var e=c.buffer.mark();b(c.model);var f=c.buffer.fromMark(e);c.isExtending=!0,d(c.model,{context:c}),c.isExtending=!1}),this.model=e},c.include=function(a,b){var c=this,d=this.buffer,e=this.model;vash.loadFile(a,this.model,function(a,d){d(b||c.model,{context:c})}),this.model=e},c.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))},c._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)},c.append=function(a,b){this._handlePrependAppend("appends",a,b)},c.prepend=function(a,b){this._handlePrependAppend("prepends",a,b)}}()
(function(){vash=typeof vash=="undefined"?{}:vash,vash.compile||(typeof define=="function"&&define.amd?define(function(){return vash}):typeof module=="object"&&module.exports?module.exports=vash:window.vash=vash);var a=vash.helpers,b=function(a){this.buffer=new f,this.model=a,this.vl=0,this.vc=0};vash.helpers=a=b.prototype={constructor:b,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer.toString()};var c=/[&<>"'`]/g,d=function(a){return e[a]},e={"&":"&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(c,d);return{toHtmlString:b,toString:b}}return a};var f=function(){this._vo=[]};f.prototype.mark=function(a){var b=new g(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},f.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},f.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[]},f.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},f.prototype.push=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},f.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(this._vo[b]==a)return b;return-1},f.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},f.prototype.index=function(a){return this._vo[a]},f.prototype.flush=function(){return this.empty().join("")},f.prototype.toString=f.prototype.toHtmlString=function(){return this._vo.join("")};var g=vash.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},h=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;g.uidLike=function(a){return(a||"").search(h)>-1},g.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},g.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.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)},vash.link=function(c,d,e){var f;if(typeof c=="string"){f=c;try{c=new Function(d,e,"__vopts","vash",f)}catch(g){a.reportError(g,0,0,f,/\n/)}}c.options={modelName:d,helpersName:e};var h=function(a,d){typeof d=="function"&&(d={onRenderEnd:d}),d=d||{},a&&a.onRenderEnd&&d&&!d.onRenderEnd&&(d.onRenderEnd=a.onRenderEnd),a&&a.onRenderEnd&&delete a.onRenderEnd;return c(a,d&&d.context||new b(a),d,vash)};h.toString=function(){return c.toString()},h.toClientString=function(){return"vash.link( "+c.toString()+', "'+d+'", "'+e+'" )'};return h},vash.lookup=function(a,b){var c=vash.helpers.tplcache[a];if(!c)throw new Error("Could not find template: "+a);return b?c(b):c},vash.install=function(a,b){var c=vash.helpers.tplcache;if(typeof b=="string"){if(!vash.compile)throw new Error("vash.install(path, [string]) is not available in the standalone runtime.");b=vash.compile(b)}return c[a]=b},vash.uninstall=function(a){var b=vash.helpers.tplcache,c=!1;if(typeof a=="string")return delete b[a];Object.keys(b).forEach(function(d){b[d]===a&&(c=delete b[d])});return c}})(),function(){var a=vash.helpers;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"),b=require("path");var c=vash.helpers;c.config.browser=!1,vash.loadFile=function(d,e,f){e=vQuery.extend({},vash.config,e||{});var g=c.config.browser,h;!g&&e.settings&&e.settings.views&&(d=b.normalize(d),d.indexOf(b.normalize(e.settings.views))===-1&&(d=b.join(e.settings.views,d)),b.extname(d)||(d+="."+(e.settings["view engine"]||"vash")));try{h=e.cache||g?c.tplcache[d]||(c.tplcache[d]=vash.compile(a.readFileSync(d,"utf8"))):vash.compile(a.readFileSync(d,"utf8")),f&&f(null,h)}catch(i){f&&f(i,null)}},vash.renderFile=function(a,b,c){vash.loadFile(a,b,function(a,d){var e=b.onRenderEnd;c(a,d(b,function(a,b){b.finishLayout(),e&&e(a,b)}))})},c._ensureLayoutProps=function(){this.appends=this.appends||{},this.prepends=this.prepends||{},this.blocks=this.blocks||{},this.blockMarks=this.blockMarks||{}},c.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.push(b)}),block=d.pop(),block&&this.buffer.push(block),f&&f.forEach(function(b){a.buffer.push(b)}),i=this.buffer.fromMark(h),i.unshift(g,0),this.buffer.spliceMark.apply(this.buffer,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()},c.extend=function(a,b){var c=this,d=this.buffer,e=this.model,f;this._ensureLayoutProps(),vash.loadFile(a,this.model,function(a,d){var e=c.buffer.mark();b(c.model);var f=c.buffer.fromMark(e);c.isExtending=!0,d(c.model,{context:c}),c.isExtending=!1}),this.model=e},c.include=function(a,b){var c=this,d=this.buffer,e=this.model;vash.loadFile(a,this.model,function(a,d){d(b||c.model,{context:c})}),this.model=e},c.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))},c._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)},c.append=function(a,b){this._handlePrependAppend("appends",a,b)},c.prepend=function(a,b){this._handlePrependAppend("prepends",a,b)}}()
/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

@@ -15,28 +15,27 @@ * https://github.com/kirbysayshi/vash

if(!vash.compile && typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(!vash.compile && typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else if(!vash.compile){
window['vash'] = vash; // BROWSER
// only fully define if this is standalone
if(!vash.compile){
if(typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else {
window['vash'] = vash; // BROWSER
}
}
var helpers = vash['helpers']
,Helpers
,Buffer;
var helpers = vash['helpers'];
if ( !helpers ) {
Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
var Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
this.vl = 0;
this.vc = 0;
};
this.vl = 0;
this.vc = 0;
};
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}};
}
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}, tplcache: {} };

@@ -63,5 +62,2 @@ // this allows a template to return the context, and coercion

// raw: explicitly prevent an expression or value from being HTML escaped.
helpers.raw = function( val ) {

@@ -106,3 +102,3 @@ var func = function() { return val; };

Buffer = function() {
var Buffer = function() {
this._vo = [];

@@ -161,3 +157,3 @@ }

if( this._vo[i] == str ){
return i;
return i;
}

@@ -241,8 +237,59 @@ }

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
lb = lb || '!LB!';
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
// ERROR REPORTING
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// VASH.LINK
// Reconstitute precompiled functions
vash['link'] = function( cmpFunc, Helpers ){
Helpers = Helpers || vash.helpers.constructor;
vash['link'] = function( cmpFunc, modelName, helpersName ){
var joined;
if( typeof cmpFunc === 'string' ){
joined = cmpFunc;
try {
cmpFunc = new Function(modelName, helpersName, '__vopts', 'vash', joined);
} catch(e){
helpers.reportError(e, 0, 0, joined, /\n/);
}
}
// need this to enable `vash.batch` to reconstitute
cmpFunc.options = { modelName: modelName, helpersName: helpersName };
var linked = function( model, opts ){

@@ -266,15 +313,15 @@

return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts );
}
return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts, vash );
};
linked.toString = function(){
return cmpFunc.toString();
}
};
linked.toClientString = function(){
return 'vash.link( ' + cmpFunc.toString() + ' )';
}
return 'vash.link( ' + cmpFunc.toString() + ', "' + modelName + '", "' + helpersName + '" )';
};
return linked;
}
};

@@ -285,35 +332,34 @@ // VASH.LINK

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// TPL CACHE
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
vash.lookup = function( path, model ){
var tpl = vash.helpers.tplcache[path];
if( !tpl ){ throw new Error('Could not find template: ' + path); }
if( model ){ return tpl(model); }
else return tpl;
};
lb = lb || '!LB!';
vash.install = function( path, tpl ){
var cache = vash.helpers.tplcache;
if( typeof tpl === 'string' ){
if( !vash.compile ){ throw new Error('vash.install(path, [string]) is not available in the standalone runtime.') }
tpl = vash.compile(tpl);
}
return cache[path] = tpl;
};
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
vash.uninstall = function( path ){
var cache = vash.helpers.tplcache
,deleted = false;
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
if( typeof path === 'string' ){
return delete cache[path];
} else {
Object.keys(cache).forEach(function(key){
if( cache[key] === path ){ deleted = delete cache[key]; }
})
return deleted;
}
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
}());
/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

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

(function(){vash=typeof vash=="undefined"?{}:vash,!vash.compile&&typeof define=="function"&&define.amd?define(function(){return vash}):!vash.compile&&typeof module=="object"&&module.exports?module.exports=vash:vash.compile||(window.vash=vash);var a=vash.helpers,b,c;a||(b=function(a){this.buffer=new c,this.model=a,this.vl=0,this.vc=0},vash.helpers=a=b.prototype={constructor:b,config:{}}),a.toString=a.toHtmlString=function(){return this.buffer.toString()};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},c=function(){this._vo=[]},c.prototype.mark=function(a){var b=new g(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},c.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},c.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[]},c.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},c.prototype.push=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},c.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(this._vo[b]==a)return b;return-1},c.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},c.prototype.index=function(a){return this._vo[a]},c.prototype.flush=function(){return this.empty().join("")},c.prototype.toString=c.prototype.toHtmlString=function(){return this._vo.join("")};var g=vash.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},h=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;g.uidLike=function(a){return(a||"").search(h)>-1},g.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},g.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)},vash.link=function(a,b){b=b||vash.helpers.constructor;var c=function(c,d){typeof d=="function"&&(d={onRenderEnd:d}),d=d||{},c&&c.onRenderEnd&&d&&!d.onRenderEnd&&(d.onRenderEnd=c.onRenderEnd),c&&c.onRenderEnd&&delete c.onRenderEnd;return a(c,d&&d.context||new b(c),d)};c.toString=function(){return a.toString()},c.toClientString=function(){return"vash.link( "+a.toString()+" )"};return c},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.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)}})()
(function(){vash=typeof vash=="undefined"?{}:vash,vash.compile||(typeof define=="function"&&define.amd?define(function(){return vash}):typeof module=="object"&&module.exports?module.exports=vash:window.vash=vash);var a=vash.helpers,b=function(a){this.buffer=new f,this.model=a,this.vl=0,this.vc=0};vash.helpers=a=b.prototype={constructor:b,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer.toString()};var c=/[&<>"'`]/g,d=function(a){return e[a]},e={"&":"&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(c,d);return{toHtmlString:b,toString:b}}return a};var f=function(){this._vo=[]};f.prototype.mark=function(a){var b=new g(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},f.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},f.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[]},f.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},f.prototype.push=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},f.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(this._vo[b]==a)return b;return-1},f.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},f.prototype.index=function(a){return this._vo[a]},f.prototype.flush=function(){return this.empty().join("")},f.prototype.toString=f.prototype.toHtmlString=function(){return this._vo.join("")};var g=vash.Mark=function(a,b){this.uid="[VASHMARK-"+~~(Math.random()*1e7)+(b?":"+b:"")+"]",this.markedIndex=0,this.buffer=a,this.destroyed=!1},h=/\[VASHMARK\-\d{1,8}(?::[\s\S]+?)?]/g;g.uidLike=function(a){return(a||"").search(h)>-1},g.prototype.destroy=function(){var a=this.findInBuffer();a>-1&&(this.buffer.splice(a,1),this.markedIndex=-1),this.destroyed=!0},g.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.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)},vash.link=function(c,d,e){var f;if(typeof c=="string"){f=c;try{c=new Function(d,e,"__vopts","vash",f)}catch(g){a.reportError(g,0,0,f,/\n/)}}c.options={modelName:d,helpersName:e};var h=function(a,d){typeof d=="function"&&(d={onRenderEnd:d}),d=d||{},a&&a.onRenderEnd&&d&&!d.onRenderEnd&&(d.onRenderEnd=a.onRenderEnd),a&&a.onRenderEnd&&delete a.onRenderEnd;return c(a,d&&d.context||new b(a),d,vash)};h.toString=function(){return c.toString()},h.toClientString=function(){return"vash.link( "+c.toString()+', "'+d+'", "'+e+'" )'};return h},vash.lookup=function(a,b){var c=vash.helpers.tplcache[a];if(!c)throw new Error("Could not find template: "+a);return b?c(b):c},vash.install=function(a,b){var c=vash.helpers.tplcache;if(typeof b=="string"){if(!vash.compile)throw new Error("vash.install(path, [string]) is not available in the standalone runtime.");b=vash.compile(b)}return c[a]=b},vash.uninstall=function(a){var b=vash.helpers.tplcache,c=!1;if(typeof a=="string")return delete b[a];Object.keys(b).forEach(function(d){b[d]===a&&(c=delete b[d])});return c}})()
/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

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

exports["version"] = "0.5.13-1803";
exports["version"] = "0.5.15-1896";
exports["config"] = {

@@ -46,2 +46,60 @@ "useWith": false

exports["compile"] = function compile(markup, options){
if(markup === '' || typeof markup !== 'string') {
throw new Error('Empty or non-string cannot be compiled');
}
var l
,tok
,tokens = []
,p
,c
,cmp
,i;
options = vQuery.extend( {}, exports.config, options || {} );
l = new VLexer(markup);
while(tok = l.advance()) { tokens.push(tok); }
tokens.reverse(); // parser needs in reverse order for faster popping vs shift
p = new VParser(tokens, options);
p.parse();
c = new VCompiler(p.ast, markup, options);
cmp = c.generate();
return cmp;
};
exports['batch'] = function batch(path, cb){
var caller = batch.caller;
function _batch(path, cb){
var reFuncHead = /^function\s*\([^)]*?\)\s*{/
,reFuncTail = /\}$/
,str = cb.toString()
.replace(reFuncHead, '')
.replace(reFuncTail, '')
,callOpts = caller.options
var cmp = new VCompiler([], '', callOpts);
str = cmp.wrapBody( str );
vash.install( path, vash.link( str, callOpts.modelName, callOpts.helpersName ) );
}
if( vash.compile ) {
exports['batch'] = _batch;
return exports['batch'](path, cb);
} else {
throw new Error('vash.batch is not available in the standalone runtime.');
}
};
/************** Begin injected code from build script */

@@ -53,28 +111,27 @@ /*jshint strict:false, asi: false, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

if(!vash.compile && typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(!vash.compile && typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else if(!vash.compile){
window['vash'] = vash; // BROWSER
// only fully define if this is standalone
if(!vash.compile){
if(typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else {
window['vash'] = vash; // BROWSER
}
}
var helpers = vash['helpers']
,Helpers
,Buffer;
var helpers = vash['helpers'];
if ( !helpers ) {
Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
var Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
this.vl = 0;
this.vc = 0;
};
this.vl = 0;
this.vc = 0;
};
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}};
}
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}, tplcache: {} };

@@ -101,5 +158,2 @@ // this allows a template to return the context, and coercion

// raw: explicitly prevent an expression or value from being HTML escaped.
helpers.raw = function( val ) {

@@ -144,3 +198,3 @@ var func = function() { return val; };

Buffer = function() {
var Buffer = function() {
this._vo = [];

@@ -199,3 +253,3 @@ }

if( this._vo[i] == str ){
return i;
return i;
}

@@ -279,8 +333,59 @@ }

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
lb = lb || '!LB!';
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
// ERROR REPORTING
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// VASH.LINK
// Reconstitute precompiled functions
vash['link'] = function( cmpFunc, Helpers ){
Helpers = Helpers || vash.helpers.constructor;
vash['link'] = function( cmpFunc, modelName, helpersName ){
var joined;
if( typeof cmpFunc === 'string' ){
joined = cmpFunc;
try {
cmpFunc = new Function(modelName, helpersName, '__vopts', 'vash', joined);
} catch(e){
helpers.reportError(e, 0, 0, joined, /\n/);
}
}
// need this to enable `vash.batch` to reconstitute
cmpFunc.options = { modelName: modelName, helpersName: helpersName };
var linked = function( model, opts ){

@@ -304,15 +409,15 @@

return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts );
}
return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts, vash );
};
linked.toString = function(){
return cmpFunc.toString();
}
};
linked.toClientString = function(){
return 'vash.link( ' + cmpFunc.toString() + ' )';
}
return 'vash.link( ' + cmpFunc.toString() + ', "' + modelName + '", "' + helpersName + '" )';
};
return linked;
}
};

@@ -323,35 +428,34 @@ // VASH.LINK

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// TPL CACHE
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
vash.lookup = function( path, model ){
var tpl = vash.helpers.tplcache[path];
if( !tpl ){ throw new Error('Could not find template: ' + path); }
if( model ){ return tpl(model); }
else return tpl;
};
lb = lb || '!LB!';
vash.install = function( path, tpl ){
var cache = vash.helpers.tplcache;
if( typeof tpl === 'string' ){
if( !vash.compile ){ throw new Error('vash.install(path, [string]) is not available in the standalone runtime.') }
tpl = vash.compile(tpl);
}
return cache[path] = tpl;
};
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
vash.uninstall = function( path ){
var cache = vash.helpers.tplcache
,deleted = false;
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
if( typeof path === 'string' ){
return delete cache[path];
} else {
Object.keys(cache).forEach(function(key){
if( cache[key] === path ){ deleted = delete cache[key]; }
})
return deleted;
}
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
}());

@@ -420,4 +524,2 @@

helpers.tplcache = {};
vash.loadFile = function(filepath, options, cb){

@@ -458,3 +560,2 @@

filepath = path.join( options.settings.views, filepath );
}

@@ -468,3 +569,2 @@

try {
// if browser, tpl must exist in tpl cache

@@ -1649,6 +1749,5 @@ tpl = options.cache || browser

function VCompiler(ast, originalMarkup, Helpers, options){
function VCompiler(ast, originalMarkup, options){
this.ast = ast;
this.originalMarkup = originalMarkup || '';
this.Helpers = Helpers || vash.helpers.constructor;
this.options = options || {};

@@ -1775,7 +1874,4 @@

VCP.generate = function(){
VCP.wrapBody = function(body){
// clear whatever's in the current buffer
this.buffer.length = 0;
var options = this.options;

@@ -1803,2 +1899,11 @@

return head + body + foot;
}
VCP.generate = function(){
var options = this.options;
// clear whatever's in the current buffer
this.buffer.length = 0;
this.visitNode(this.ast);

@@ -1813,3 +1918,3 @@

joined = head + joined + foot;
joined = this.wrapBody( joined );

@@ -1820,15 +1925,6 @@ if(options.debugCompiler){

try {
this.cmpFunc = new Function(options.modelName, options.helpersName, '__vopts', joined);
} catch(e){
this.Helpers.reportError(e, 0, 0, joined, /\n/)
}
return this.compiledFunc;
this.cmpFunc = vash.link( joined, options.modelName, options.helpersName );
return this.cmpFunc;
}
VCP.assemble = function( cmpFunc ){
return vash.link( cmpFunc || this.cmpFunc, this.Helpers );
}
VCompiler.noop = function(){}

@@ -1856,33 +1952,3 @@

exports["compile"] = function compile(markup, options){
if(markup === '' || typeof markup !== 'string') {
throw new Error('Empty or non-string cannot be compiled');
}
var l
,tok
,tokens = []
,p
,c
,cmp
,i;
options = vQuery.extend( {}, exports.config, options || {} );
l = new VLexer(markup);
while(tok = l.advance()) { tokens.push(tok); }
tokens.reverse(); // parser needs in reverse order for faster popping vs shift
p = new VParser(tokens, options);
p.parse();
c = new VCompiler(p.ast, markup, exports.helpers.constructor, options);
cmp = c.generate();
cmp = c.assemble( cmp );
return cmp;
};
return exports;
}({}));
/**
* Vash - JavaScript Template Parser, v0.5.13-1803
* Vash - JavaScript Template Parser, v0.5.15-1896
*

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

(function(a){typeof define=="function"&&define.amd?define(function(){return a}):typeof module=="object"&&module.exports?module.exports=a:window.vash=a})(function(a){function Q(a,c,d,e){this.ast=a,this.originalMarkup=c||"",this.Helpers=d||b.helpers.constructor,this.options=e||{},this.reQuote=/(["'])/gi,this.reEscapedQuote=/\\+(["'])/gi,this.reLineBreak=/[\n\r]/gi,this.reHelpersName=/HELPERSNAME/g,this.reModelName=/MODELNAME/g,this.reOriginalMarkup=/ORIGINALMARKUP/g,this.buffer=[]}function L(a,b){this.options=b||{},this.tokens=a,this.ast=K(M),this.prevTokens=[]}function J(a){this.input=this.originalInput=a.replace(/\r\n|\r/g,"\n"),this.lineno=1,this.charno=0}var b=a;a.version="0.5.13-1803",a.config={useWith:!1,modelName:"model",helpersName:"html",htmlEscape:!0,debug:!0,debugParser:!1,debugCompiler:!1,favorText:!1,saveTextTag:!1,saveAT:!1},function(){b=typeof b=="undefined"?{}:b,!b.compile&&typeof define=="function"&&define.amd?define(function(){return b}):!b.compile&&typeof module=="object"&&module.exports?module.exports=b:b.compile||(window.vash=b);var a=b.helpers,c,d;a||(c=function(a){this.buffer=new d,this.model=a,this.vl=0,this.vc=0},b.helpers=a=c.prototype={constructor:c,config:{}}),a.toString=a.toHtmlString=function(){return this.buffer.toString()};var e=/[&<>"'`]/g,f=function(a){return g[a]},g={"&":"&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(e,f);return{toHtmlString:b,toString:b}}return a},d=function(){this._vo=[]},d.prototype.mark=function(a){var b=new h(this,a);b.markedIndex=this._vo.length,this._vo.push(b.uid);return b},d.prototype.fromMark=function(a){var b=a.findInBuffer();if(b>-1){a.destroy();return this._vo.splice(b,this._vo.length)}return[]},d.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[]},d.prototype.empty=function(){return this._vo.splice(0,this._vo.length)},d.prototype.push=function(a){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},d.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(this._vo[b]==a)return b;return-1},d.prototype.splice=function(){return this._vo.splice.apply(this._vo,arguments)},d.prototype.index=function(a){return this._vo[a]},d.prototype.flush=function(){return this.empty().join("")},d.prototype.toString=d.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)},b.link=function(a,c){c=c||b.helpers.constructor;var d=function(b,d){typeof d=="function"&&(d={onRenderEnd:d}),d=d||{},b&&b.onRenderEnd&&d&&!d.onRenderEnd&&(d.onRenderEnd=b.onRenderEnd),b&&b.onRenderEnd&&delete b.onRenderEnd;return a(b,d&&d.context||new c(b),d)};d.toString=function(){return a.toString()},d.toClientString=function(){return"vash.link( "+a.toString()+" )"};return d},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.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)}}(),function(){var a=b.helpers;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,d.tplcache={},b.loadFile=function(e,f,g){f=K.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,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.push(b)}),block=d.pop(),block&&this.buffer.push(block),f&&f.forEach(function(b){a.buffer.push(b)}),i=this.buffer.fromMark(h),i.unshift(g,0),this.buffer.spliceMark.apply(this.buffer,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;var 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="FAT_ARROW",o="FUNCTION",p="HARD_PAREN_CLOSE",q="HARD_PAREN_OPEN",r="HTML_TAG_CLOSE",s="HTML_TAG_OPEN",t="HTML_TAG_SELFCLOSE",u="IDENTIFIER",v="KEYWORD",w="LOGICAL",x="NEWLINE",y="NUMERIC_CONTENT",z="OPERATOR",A="PAREN_CLOSE",B="PAREN_OPEN",C="PERIOD",D="SINGLE_QUOTE",E="TEXT_TAG_CLOSE",F="TEXT_TAG_OPEN",G="WHITESPACE",H={};H[g]=f,H[j]=i,H[l]=l,H[q]=p,H[B]=A,H[D]=D,H[e]=x;var I=[m,/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:ca|co\.uk|com|edu|net|org))\b/,g,/^(@\*)/,f,/^(\*@)/,e,/^(@\:)/,c,/^(@)/,n,/^(\(.*?\)?\s*?=>)/,B,/^(\()/,A,/^(\))/,q,/^(\[)/,p,/^(\])/,j,/^(\{)/,i,/^(\})/,F,/^(<text>)/,E,/^(<\/text>)/,t,/^(<[^@>]+?\/>)/,s,function(){var a=/^(<[^\/=+< >]+?[^>]*?>)/,b=/([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/,c=this.scan(a,s);c&&(this.spewIf(c,b),this.spewIf(c,/(@)/));return c},r,/^(<\/[^>@\b]+?>)/,C,/^(\.)/,x,function(){var a=this.scan(/^(\n)/,x);a&&(this.lineno++,this.charno=0);return a},G,/^(\s)/,o,/^(function)(?![\d\w])/,v,/^(case|catch|do|else|finally|for|function|goto|if|instanceof|return|switch|try|typeof|var|while|with)(?![\d\w])/,u,/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/,z,/^(===|!==|==|!==|>>>|<<|>>|>=|<=|>|<|\+|-|\/|\*|\^|%|\:|\?)/,d,/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=|=)/,w,/^(&&|\|\||&|\||\^)/,h,/^(\\)/,l,/^(\")/,D,/^(\')/,y,/^([0-9]+)/,k,/^([^\s})@.]+?)/];J.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<I.length;a+=2){c=I[a+1],c.displayName=I[a],typeof c=="function"&&(d=c.call(this)),typeof c.exec=="function"&&(d=this.scan(c,I[a]));if(d)return d}}};var K=function(a){return new K.fn.init(a)};K.prototype.init=function(a){typeof a=="string"&&(this.mode=a),this.maxCheck()},K.fn=K.prototype.init.prototype=K.prototype,K.fn.vquery="yep",K.fn.constructor=K,K.fn.length=0,K.fn.parent=null,K.fn.mode=null,K.fn.tagName=null,K.fn.beget=function(a,b){var c=K(a);c.parent=this,this.push(c),b&&(c.tagName=b),this.maxCheck();return c},K.fn.closest=function(a,b){var c=this;while(c)if(c.tagName!==b&&c.parent)c=c.parent;else break;return c},K.fn.pushFlatten=function(a){var b=a,c,d;while(b.length===1&&b[0].vquery)b=b[0];if(b.mode!==M)this.push(b);else for(c=0;c<b.length;c++)this.push(b[c]);this.maxCheck();return this},K.fn.push=function(a){K.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},K.fn.root=function(){var a=this;while(a&&a.parent&&(a=a.parent));return a},K.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===K.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")},K.fn.maxCheck=function(a){if(this.length>=K.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}},K.maxSize=1e3,K.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},[])},K.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},K(M))},K.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"},K.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},K.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")K.fn[c]||function(a){K.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)}},K.takeMethodsFromArray();var M="PROGRAM",N="MARKUP",O="BLOCK",P="EXPRESSION";L.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===M||this.ast.mode===null)this.ast=this.ast.beget(this.options.initialMode||N),this.options.initialMode===P&&(this.ast=this.ast.beget(P));if(this.ast.mode===N){this.handleMKP(a);continue}if(this.ast.mode===O){this.handleBLK(a);continue}if(this.ast.mode===P){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=K.extend({},this.options);h.initialMode=b,e=this.advanceUntilMatched(a,a.type,H[a.type],null,c),e.pop(),f=e.shift(),d||this.ast.push(a),g=new L(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],e=null,h;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 B:case u:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(P);break;case v:case o:case j:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(O);break;case c:b.type="CONTENT",this.ast.push(this.tokens.pop());break;default:this.ast.push(this.tokens.pop())}}break;case F:case s:e=a.val.match(/^<([^\/ >]+)/i),e===null&&b&&b.type===c&&d&&(e=d.val.match(/(.*)/)),this.ast.tagName?this.ast=this.ast.beget(N,e[1]):this.ast.tagName=e[1],(s===a.type||this.options.saveTextTag)&&this.ast.push(a);break;case E:case r:e=a.val.match(/^<\/([^>]+)/i),e===null&&b&&b.type===c&&d&&(e=d.val.match(/(.*)/)),h=this.ast.closest(N,e[1]),h!==null&&h.tagName===e[1]&&(this.ast=h),(r===a.type||this.options.saveTextTag)&&this.ast.push(a),this.ast.parent&&this.ast.parent.mode===O&&(this.ast=this.ast.parent);break;case t:this.ast.push(a),this.ast.parent&&this.ast.parent.mode===O&&(this.ast=this.ast.parent);break;default:this.ast.push(a)}},handleBLK:function(a){var b=this.tokens[this.tokens.length-1],d,h,i,k,l,m,n;switch(a.type){case c:b.type!==c&&(this.tokens.push(a),this.ast=this.ast.beget(N));break;case g:this.advanceUntilMatched(a,g,f,c,c);break;case e:this.subParse(a,N,!0);break;case F:case E:case t:case s:case r:this.ast=this.ast.beget(N),this.tokens.push(a);break;case j:case B:d=this.options.favorText&&a.type===j?N:O,this.subParse(a,d),k=this.advanceUntilNot(G),b=this.tokens[this.tokens.length-1],b&&b.type!==v&&b.type!==o&&b.type!==j&&a.type!==B?(this.tokens.push.apply(this.tokens,k.reverse()),this.ast=this.ast.parent):this.ast.push(k);break;case G:this.ast.push(a),this.advanceUntilNot(G);break;default:this.ast.push(a)}},handleEXP:function(a){var b=null,e,f,g,i,k,m,r;switch(a.type){case v:case o:this.ast=this.ast.beget(O),this.tokens.push(a);break;case G:case w:case d:case z:case y:this.ast.parent&&this.ast.parent.mode===P?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;case u:this.ast.push(a);break;case D:case l:this.ast.parent&&this.ast.parent.mode===P?(k=this.advanceUntilMatched(a,a.type,H[a.type],h,h),this.ast.pushFlatten(k.reverse())):(this.ast=this.ast.parent,this.tokens.push(a));break;case q:case B:m=this.prevTokens[this.prevTokens.length-1],b=this.tokens[this.tokens.length-1];if(a.type===q&&b.type===p){this.tokens.push(a),this.ast=this.ast.parent;break}this.subParse(a,P),b=this.tokens[this.tokens.length-1];if(m&&m.type===c||b&&b.type===u)this.ast=this.ast.parent;break;case j:this.tokens.push(a),this.ast=this.ast.beget(O);break;case n:this.tokens.push(a),this.ast=this.ast.beget(O);break;case C:b=this.tokens[this.tokens.length-1],b&&(b.type===u||b.type===v||b.type===o||b.type===C||this.ast.parent&&this.ast.parent.mode===P)?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;default:this.ast.parent&&this.ast.parent.mode!==P?(this.ast=this.ast.parent,this.tokens.push(a)):this.ast.push(a)}}};var R=Q.prototype;R.insertDebugVars=function(a){this.options.debug&&this.buffer.push(this.options.helpersName+".vl = "+a.line+", ",this.options.helpersName+".vc = "+a.chr+"; \n")},R.visitMarkupTok=function(a,b,c){this.insertDebugVars(a),this.buffer.push("MKP('"+a.val.replace(this.reQuote,"\\$1").replace(this.reLineBreak,"\\n")+"')MKP")},R.visitBlockTok=function(a,b,c){this.buffer.push(a.val)},R.visitExpressionTok=function(a,b,c,d){var e="",f="",g=b.parent&&b.parent.mode!==P;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)},R.visitNode=function(a){var b,d=a.slice(0),f,g,h;a.mode===P&&a.parent&&a.parent.mode!==P&&(f=a.filter(Q.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===N?this.visitMarkupTok(h,a,g):a.mode===O?this.visitBlockTok(h,a,g):a.mode===P&&this.visitExpressionTok(h,a,g,f>0?!1:!0)}},R.escapeForDebug=function(a){return a.replace(this.reLineBreak,"!LB!").replace(this.reQuote,"\\$1").replace(this.reEscapedQuote,"\\$1")},R.replaceDevTokens=function(a){return a.replace(this.reHelpersName,this.options.helpersName).replace(this.reModelName,this.options.modelName)},R.generate=function(){this.buffer.length=0;var a=this.options,b=""+(a.debug?"try { \n":"")+"var __vbuffer = HELPERSNAME.buffer; \n"+"MODELNAME = MODELNAME || {}; \n"+(a.useWith?"with( MODELNAME ){ \n":""),c="(__vopts && __vopts.onRenderEnd && __vopts.onRenderEnd(null, HELPERSNAME)); \nreturn (__vopts && __vopts.asContext) \n ? HELPERSNAME \n : HELPERSNAME.toString(); \n"+(a.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"")+(a.useWith?"} \n":"");b=this.replaceDevTokens(b),c=this.replaceDevTokens(c).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup)),this.visitNode(this.ast);var d=this.buffer.join("").split("')MKPMKP('").join("").split("MKP(").join("__vbuffer.push(").split(")MKP").join("); \n");d=b+d+c,a.debugCompiler&&console.log(d);try{this.cmpFunc=new Function(a.modelName,a.helpersName,"__vopts",d)}catch(e){this.Helpers.reportError(e,0,0,d,/\n/)}return this.compiledFunc},R.assemble=function(a){return b.link(a||this.cmpFunc,this.Helpers)},Q.noop=function(){},Q.findNonExp=function(a){return a.vquery&&a.mode===P?a.filter(Q.findNonExp).length>0:a.vquery&&a.mode!==P?!0:!1},a.VLexer=J,a.VParser=L,a.VCompiler=Q,a.vQuery=K,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=K.extend({},a.config,c||{}),d=new J(b);while(e=d.advance())f.push(e);f.reverse(),g=new L(f,c),g.parse(),h=new Q(g.ast,b,a.helpers.constructor,c),i=h.generate(),i=h.assemble(i);return i};return a}({}))
(function(a){typeof define=="function"&&define.amd?define(function(){return a}):typeof module=="object"&&module.exports?module.exports=a:window.vash=a})(function(a){function Q(a,b,c){this.ast=a,this.originalMarkup=b||"",this.options=c||{},this.reQuote=/(["'])/gi,this.reEscapedQuote=/\\+(["'])/gi,this.reLineBreak=/[\n\r]/gi,this.reHelpersName=/HELPERSNAME/g,this.reModelName=/MODELNAME/g,this.reOriginalMarkup=/ORIGINALMARKUP/g,this.buffer=[]}function L(a,b){this.options=b||{},this.tokens=a,this.ast=K(M),this.prevTokens=[]}function J(a){this.input=this.originalInput=a.replace(/\r\n|\r/g,"\n"),this.lineno=1,this.charno=0}var b=a;a.version="0.5.15-1896",a.config={useWith:!1,modelName:"model",helpersName:"html",htmlEscape:!0,debug:!0,debugParser:!1,debugCompiler:!1,favorText:!1,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=K.extend({},a.config,c||{}),d=new J(b);while(e=d.advance())f.push(e);f.reverse(),g=new L(f,c),g.parse(),h=new Q(g.ast,b,c),i=h.generate();return i},a.batch=function T(c,d){function f(a,c){var d=/^function\s*\([^)]*?\)\s*{/,f=/\}$/,g=c.toString().replace(d,"").replace(f,""),h=e.options,i=new Q([],"",h);g=i.wrapBody(g),b.install(a,b.link(g,h.modelName,h.helpersName))}var e=T.caller;if(b.compile){a.batch=f;return a.batch(c,d)}throw new Error("vash.batch is not available in the standalone runtime.")},function(){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.vl=0,this.vc=0};b.helpers=a=c.prototype={constructor:c,config:{},tplcache:{}},a.toString=a.toHtmlString=function(){return this.buffer.toString()};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){a instanceof Array?this._vo.push.apply(this._vo,a):arguments.length>1?this._vo.push.apply(this._vo,Array.prototype.slice.call(arguments)):this._vo.push(a)},g.prototype.indexOf=function(a){for(var b=0;b<this._vo.length;b++)if(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.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,f){var g;if(typeof d=="string"){g=d;try{d=new Function(e,f,"__vopts","vash",g)}catch(h){a.reportError(h,0,0,g,/\n/)}}d.options={modelName:e,helpersName:f};var i=function(a,e){typeof e=="function"&&(e={onRenderEnd:e}),e=e||{},a&&a.onRenderEnd&&e&&!e.onRenderEnd&&(e.onRenderEnd=a.onRenderEnd),a&&a.onRenderEnd&&delete a.onRenderEnd;return d(a,e&&e.context||new c(a),e,b)};i.toString=function(){return d.toString()},i.toClientString=function(){return"vash.link( "+d.toString()+', "'+e+'", "'+f+'" )'};return i},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)}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.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=K.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,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.push(b)}),block=d.pop(),block&&this.buffer.push(block),f&&f.forEach(function(b){a.buffer.push(b)}),i=this.buffer.fromMark(h),i.unshift(g,0),this.buffer.spliceMark.apply(this.buffer,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;var 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="FAT_ARROW",o="FUNCTION",p="HARD_PAREN_CLOSE",q="HARD_PAREN_OPEN",r="HTML_TAG_CLOSE",s="HTML_TAG_OPEN",t="HTML_TAG_SELFCLOSE",u="IDENTIFIER",v="KEYWORD",w="LOGICAL",x="NEWLINE",y="NUMERIC_CONTENT",z="OPERATOR",A="PAREN_CLOSE",B="PAREN_OPEN",C="PERIOD",D="SINGLE_QUOTE",E="TEXT_TAG_CLOSE",F="TEXT_TAG_OPEN",G="WHITESPACE",H={};H[g]=f,H[j]=i,H[l]=l,H[q]=p,H[B]=A,H[D]=D,H[e]=x;var I=[m,/^([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.(?:ca|co\.uk|com|edu|net|org))\b/,g,/^(@\*)/,f,/^(\*@)/,e,/^(@\:)/,c,/^(@)/,n,/^(\(.*?\)?\s*?=>)/,B,/^(\()/,A,/^(\))/,q,/^(\[)/,p,/^(\])/,j,/^(\{)/,i,/^(\})/,F,/^(<text>)/,E,/^(<\/text>)/,t,/^(<[^@>]+?\/>)/,s,function(){var a=/^(<[^\/=+< >]+?[^>]*?>)/,b=/([a-zA-Z0-9.%]+@[a-zA-Z0-9.\-]+\.[a-zA-Z]{2,4})\b/,c=this.scan(a,s);c&&(this.spewIf(c,b),this.spewIf(c,/(@)/));return c},r,/^(<\/[^>@\b]+?>)/,C,/^(\.)/,x,function(){var a=this.scan(/^(\n)/,x);a&&(this.lineno++,this.charno=0);return a},G,/^(\s)/,o,/^(function)(?![\d\w])/,v,/^(case|catch|do|else|finally|for|function|goto|if|instanceof|return|switch|try|typeof|var|while|with)(?![\d\w])/,u,/^([_$a-zA-Z\xA0-\uFFFF][_$a-zA-Z0-9\xA0-\uFFFF]*)/,z,/^(===|!==|==|!==|>>>|<<|>>|>=|<=|>|<|\+|-|\/|\*|\^|%|\:|\?)/,d,/^(\|=|\^=|&=|>>>=|>>=|<<=|-=|\+=|%=|\/=|\*=|=)/,w,/^(&&|\|\||&|\||\^)/,h,/^(\\)/,l,/^(\")/,D,/^(\')/,y,/^([0-9]+)/,k,/^([^\s})@.]+?)/];J.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<I.length;a+=2){c=I[a+1],c.displayName=I[a],typeof c=="function"&&(d=c.call(this)),typeof c.exec=="function"&&(d=this.scan(c,I[a]));if(d)return d}}};var K=function(a){return new K.fn.init(a)};K.prototype.init=function(a){typeof a=="string"&&(this.mode=a),this.maxCheck()},K.fn=K.prototype.init.prototype=K.prototype,K.fn.vquery="yep",K.fn.constructor=K,K.fn.length=0,K.fn.parent=null,K.fn.mode=null,K.fn.tagName=null,K.fn.beget=function(a,b){var c=K(a);c.parent=this,this.push(c),b&&(c.tagName=b),this.maxCheck();return c},K.fn.closest=function(a,b){var c=this;while(c)if(c.tagName!==b&&c.parent)c=c.parent;else break;return c},K.fn.pushFlatten=function(a){var b=a,c,d;while(b.length===1&&b[0].vquery)b=b[0];if(b.mode!==M)this.push(b);else for(c=0;c<b.length;c++)this.push(b[c]);this.maxCheck();return this},K.fn.push=function(a){K.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},K.fn.root=function(){var a=this;while(a&&a.parent&&(a=a.parent));return a},K.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===K.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")},K.fn.maxCheck=function(a){if(this.length>=K.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}},K.maxSize=1e3,K.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},[])},K.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},K(M))},K.isArray=function(a){return Object.prototype.toString.call(a)=="[object Array]"},K.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},K.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")K.fn[c]||function(a){K.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)}},K.takeMethodsFromArray();var M="PROGRAM",N="MARKUP",O="BLOCK",P="EXPRESSION";L.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===M||this.ast.mode===null)this.ast=this.ast.beget(this.options.initialMode||N),this.options.initialMode===P&&(this.ast=this.ast.beget(P));if(this.ast.mode===N){this.handleMKP(a);continue}if(this.ast.mode===O){this.handleBLK(a);continue}if(this.ast.mode===P){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=K.extend({},this.options);h.initialMode=b,e=this.advanceUntilMatched(a,a.type,H[a.type],null,c),e.pop(),f=e.shift(),d||this.ast.push(a),g=new L(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],e=null,h;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 B:case u:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(P);break;case v:case o:case j:this.ast.length===0&&(this.ast=this.ast.parent,this.ast.pop()),this.ast=this.ast.beget(O);break;case c:b.type="CONTENT",this.ast.push(this.tokens.pop());break;default:this.ast.push(this.tokens.pop())}}break;case F:case s:e=a.val.match(/^<([^\/ >]+)/i),e===null&&b&&b.type===c&&d&&(e=d.val.match(/(.*)/)),this.ast.tagName?this.ast=this.ast.beget(N,e[1]):this.ast.tagName=e[1],(s===a.type||this.options.saveTextTag)&&this.ast.push(a);break;case E:case r:e=a.val.match(/^<\/([^>]+)/i),e===null&&b&&b.type===c&&d&&(e=d.val.match(/(.*)/)),h=this.ast.closest(N,e[1]),h!==null&&h.tagName===e[1]&&(this.ast=h),(r===a.type||this.options.saveTextTag)&&this.ast.push(a),this.ast.parent&&this.ast.parent.mode===O&&(this.ast=this.ast.parent);break;case t:this.ast.push(a),this.ast.parent&&this.ast.parent.mode===O&&(this.ast=this.ast.parent);break;default:this.ast.push(a)}},handleBLK:function(a){var b=this.tokens[this.tokens.length-1],d,h,i,k,l,m,n;switch(a.type){case c:b.type!==c&&(this.tokens.push(a),this.ast=this.ast.beget(N));break;case g:this.advanceUntilMatched(a,g,f,c,c);break;case e:this.subParse(a,N,!0);break;case F:case E:case t:case s:case r:this.ast=this.ast.beget(N),this.tokens.push(a);break;case j:case B:d=this.options.favorText&&a.type===j?N:O,this.subParse(a,d),k=this.advanceUntilNot(G),b=this.tokens[this.tokens.length-1],b&&b.type!==v&&b.type!==o&&b.type!==j&&a.type!==B?(this.tokens.push.apply(this.tokens,k.reverse()),this.ast=this.ast.parent):this.ast.push(k);break;case G:this.ast.push(a),this.advanceUntilNot(G);break;default:this.ast.push(a)}},handleEXP:function(a){var b=null,e,f,g,i,k,m,r;switch(a.type){case v:case o:this.ast=this.ast.beget(O),this.tokens.push(a);break;case G:case w:case d:case z:case y:this.ast.parent&&this.ast.parent.mode===P?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;case u:this.ast.push(a);break;case D:case l:this.ast.parent&&this.ast.parent.mode===P?(k=this.advanceUntilMatched(a,a.type,H[a.type],h,h),this.ast.pushFlatten(k.reverse())):(this.ast=this.ast.parent,this.tokens.push(a));break;case q:case B:m=this.prevTokens[this.prevTokens.length-1],b=this.tokens[this.tokens.length-1];if(a.type===q&&b.type===p){this.tokens.push(a),this.ast=this.ast.parent;break}this.subParse(a,P),b=this.tokens[this.tokens.length-1];if(m&&m.type===c||b&&b.type===u)this.ast=this.ast.parent;break;case j:this.tokens.push(a),this.ast=this.ast.beget(O);break;case n:this.tokens.push(a),this.ast=this.ast.beget(O);break;case C:b=this.tokens[this.tokens.length-1],b&&(b.type===u||b.type===v||b.type===o||b.type===C||this.ast.parent&&this.ast.parent.mode===P)?this.ast.push(a):(this.ast=this.ast.parent,this.tokens.push(a));break;default:this.ast.parent&&this.ast.parent.mode!==P?(this.ast=this.ast.parent,this.tokens.push(a)):this.ast.push(a)}}};var R=Q.prototype;R.insertDebugVars=function(a){this.options.debug&&this.buffer.push(this.options.helpersName+".vl = "+a.line+", ",this.options.helpersName+".vc = "+a.chr+"; \n")},R.visitMarkupTok=function(a,b,c){this.insertDebugVars(a),this.buffer.push("MKP('"+a.val.replace(this.reQuote,"\\$1").replace(this.reLineBreak,"\\n")+"')MKP")},R.visitBlockTok=function(a,b,c){this.buffer.push(a.val)},R.visitExpressionTok=function(a,b,c,d){var e="",f="",g=b.parent&&b.parent.mode!==P;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)},R.visitNode=function(a){var b,d=a.slice(0),f,g,h;a.mode===P&&a.parent&&a.parent.mode!==P&&(f=a.filter(Q.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===N?this.visitMarkupTok(h,a,g):a.mode===O?this.visitBlockTok(h,a,g):a.mode===P&&this.visitExpressionTok(h,a,g,f>0?!1:!0)}},R.escapeForDebug=function(a){return a.replace(this.reLineBreak,"!LB!").replace(this.reQuote,"\\$1").replace(this.reEscapedQuote,"\\$1")},R.replaceDevTokens=function(a){return a.replace(this.reHelpersName,this.options.helpersName).replace(this.reModelName,this.options.modelName)},R.wrapBody=function(a){var b=this.options,c=""+(b.debug?"try { \n":"")+"var __vbuffer = HELPERSNAME.buffer; \n"+"MODELNAME = MODELNAME || {}; \n"+(b.useWith?"with( MODELNAME ){ \n":""),d="(__vopts && __vopts.onRenderEnd && __vopts.onRenderEnd(null, HELPERSNAME)); \nreturn (__vopts && __vopts.asContext) \n ? HELPERSNAME \n : HELPERSNAME.toString(); \n"+(b.debug?'} catch( e ){ \n HELPERSNAME.reportError( e, HELPERSNAME.vl, HELPERSNAME.vc, "ORIGINALMARKUP" ); \n} \n':"")+(b.useWith?"} \n":"");c=this.replaceDevTokens(c),d=this.replaceDevTokens(d).replace(this.reOriginalMarkup,this.escapeForDebug(this.originalMarkup));return c+a+d},R.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");c=this.wrapBody(c),a.debugCompiler&&console.log(c),this.cmpFunc=b.link(c,a.modelName,a.helpersName);return this.cmpFunc},Q.noop=function(){},Q.findNonExp=function(a){return a.vquery&&a.mode===P?a.filter(Q.findNonExp).length>0:a.vquery&&a.mode!==P?!0:!1},a.VLexer=J,a.VParser=L,a.VCompiler=Q,a.vQuery=K;return a}({}))
{
"name": "vash",
"description": "Razor syntax for JS templating",
"version": "0.5.14-1803",
"version": "0.5.15-1896",
"author": "Andrew Petersen <senofpeter@gmail.com>",

@@ -39,2 +39,2 @@ "homepage": "https://github.com/kirbysayshi/vash",

}
}
}

@@ -36,11 +36,2 @@ /*jshint strict:false, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

/************** Begin injected code from build script */
/*?CODE?*/
/************** End injected code from build script */
exports["VLexer"] = VLexer;
exports["VParser"] = VParser;
exports["VCompiler"] = VCompiler;
exports["vQuery"] = vQuery;
exports["compile"] = function compile(markup, options){

@@ -69,10 +60,47 @@

c = new VCompiler(p.ast, markup, exports.helpers.constructor, options);
c = new VCompiler(p.ast, markup, options);
cmp = c.generate();
cmp = c.assemble( cmp );
return cmp;
};
exports['batch'] = function batch(path, cb){
var caller = batch.caller;
function _batch(path, cb){
var reFuncHead = /^function\s*\([^)]*?\)\s*{/
,reFuncTail = /\}$/
,str = cb.toString()
.replace(reFuncHead, '')
.replace(reFuncTail, '')
,callOpts = caller.options
var cmp = new VCompiler([], '', callOpts);
str = cmp.wrapBody( str );
vash.install( path, vash.link( str, callOpts.modelName, callOpts.helpersName ) );
}
if( vash.compile ) {
exports['batch'] = _batch;
return exports['batch'](path, cb);
} else {
throw new Error('vash.batch is not available in the standalone runtime.');
}
};
/************** Begin injected code from build script */
/*?CODE?*/
/************** End injected code from build script */
exports["VLexer"] = VLexer;
exports["VParser"] = VParser;
exports["VCompiler"] = VCompiler;
exports["vQuery"] = vQuery;
return exports;
}({}));
/*jshint strict:false, asi:true, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */
function VCompiler(ast, originalMarkup, Helpers, options){
function VCompiler(ast, originalMarkup, options){
this.ast = ast;
this.originalMarkup = originalMarkup || '';
this.Helpers = Helpers || vash.helpers.constructor;
this.options = options || {};

@@ -128,7 +127,4 @@

VCP.generate = function(){
VCP.wrapBody = function(body){
// clear whatever's in the current buffer
this.buffer.length = 0;
var options = this.options;

@@ -156,2 +152,11 @@

return head + body + foot;
}
VCP.generate = function(){
var options = this.options;
// clear whatever's in the current buffer
this.buffer.length = 0;
this.visitNode(this.ast);

@@ -166,3 +171,3 @@

joined = head + joined + foot;
joined = this.wrapBody( joined );

@@ -173,15 +178,6 @@ if(options.debugCompiler){

try {
this.cmpFunc = new Function(options.modelName, options.helpersName, '__vopts', joined);
} catch(e){
this.Helpers.reportError(e, 0, 0, joined, /\n/)
}
return this.compiledFunc;
this.cmpFunc = vash.link( joined, options.modelName, options.helpersName );
return this.cmpFunc;
}
VCP.assemble = function( cmpFunc ){
return vash.link( cmpFunc || this.cmpFunc, this.Helpers );
}
VCompiler.noop = function(){}

@@ -188,0 +184,0 @@

@@ -18,4 +18,2 @@ ;(function(){

helpers.tplcache = {};
vash.loadFile = function(filepath, options, cb){

@@ -56,3 +54,2 @@

filepath = path.join( options.settings.views, filepath );
}

@@ -66,3 +63,2 @@

try {
// if browser, tpl must exist in tpl cache

@@ -69,0 +65,0 @@ tpl = options.cache || browser

@@ -6,28 +6,27 @@ /*jshint strict:false, asi: false, laxcomma:true, laxbreak:true, boss:true, curly:true, node:true, browser:true, devel:true */

if(!vash.compile && typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(!vash.compile && typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else if(!vash.compile){
window['vash'] = vash; // BROWSER
// only fully define if this is standalone
if(!vash.compile){
if(typeof define === 'function' && define['amd']){
define(function(){ return vash }); // AMD
} else if(typeof module === 'object' && module['exports']){
module['exports'] = vash; // NODEJS
} else {
window['vash'] = vash; // BROWSER
}
}
var helpers = vash['helpers']
,Helpers
,Buffer;
var helpers = vash['helpers'];
if ( !helpers ) {
Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
var Helpers = function ( model ) {
this.buffer = new Buffer();
this.model = model;
this.vl = 0;
this.vc = 0;
};
this.vl = 0;
this.vc = 0;
};
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}};
}
vash['helpers']
= helpers
= Helpers.prototype
= { constructor: Helpers, config: {}, tplcache: {} };

@@ -54,5 +53,2 @@ // this allows a template to return the context, and coercion

// raw: explicitly prevent an expression or value from being HTML escaped.
helpers.raw = function( val ) {

@@ -97,3 +93,3 @@ var func = function() { return val; };

Buffer = function() {
var Buffer = function() {
this._vo = [];

@@ -152,3 +148,3 @@ }

if( this._vo[i] == str ){
return i;
return i;
}

@@ -232,8 +228,59 @@ }

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
lb = lb || '!LB!';
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
// ERROR REPORTING
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
// VASH.LINK
// Reconstitute precompiled functions
vash['link'] = function( cmpFunc, Helpers ){
Helpers = Helpers || vash.helpers.constructor;
vash['link'] = function( cmpFunc, modelName, helpersName ){
var joined;
if( typeof cmpFunc === 'string' ){
joined = cmpFunc;
try {
cmpFunc = new Function(modelName, helpersName, '__vopts', 'vash', joined);
} catch(e){
helpers.reportError(e, 0, 0, joined, /\n/);
}
}
// need this to enable `vash.batch` to reconstitute
cmpFunc.options = { modelName: modelName, helpersName: helpersName };
var linked = function( model, opts ){

@@ -257,15 +304,15 @@

return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts );
}
return cmpFunc( model, (opts && opts.context) || new Helpers( model ), opts, vash );
};
linked.toString = function(){
return cmpFunc.toString();
}
};
linked.toClientString = function(){
return 'vash.link( ' + cmpFunc.toString() + ' )';
}
return 'vash.link( ' + cmpFunc.toString() + ', "' + modelName + '", "' + helpersName + '" )';
};
return linked;
}
};

@@ -276,35 +323,34 @@ // VASH.LINK

///////////////////////////////////////////////////////////////////////////
// ERROR REPORTING
// TPL CACHE
// Liberally modified from https://github.com/visionmedia/jade/blob/master/jade.js
helpers.constructor.reportError = function(e, lineno, chr, orig, lb){
vash.lookup = function( path, model ){
var tpl = vash.helpers.tplcache[path];
if( !tpl ){ throw new Error('Could not find template: ' + path); }
if( model ){ return tpl(model); }
else return tpl;
};
lb = lb || '!LB!';
vash.install = function( path, tpl ){
var cache = vash.helpers.tplcache;
if( typeof tpl === 'string' ){
if( !vash.compile ){ throw new Error('vash.install(path, [string]) is not available in the standalone runtime.') }
tpl = vash.compile(tpl);
}
return cache[path] = tpl;
};
var lines = orig.split(lb)
,contextSize = lineno === 0 && chr === 0 ? lines.length - 1 : 3
,start = Math.max(0, lineno - contextSize)
,end = Math.min(lines.length, lineno + contextSize);
vash.uninstall = function( path ){
var cache = vash.helpers.tplcache
,deleted = false;
var contextStr = lines.slice(start, end).map(function(line, i, all){
var curr = i + start + 1;
return (curr === lineno ? ' > ' : ' ')
+ (curr < 10 ? ' ' : '')
+ curr
+ ' | '
+ line;
}).join('\n');
e.message = 'Problem while rendering template at line '
+ lineno + ', character ' + chr
+ '.\nOriginal message: ' + e.message + '.'
+ '\nContext: \n\n' + contextStr + '\n\n';
throw e;
if( typeof path === 'string' ){
return delete cache[path];
} else {
Object.keys(cache).forEach(function(key){
if( cache[key] === path ){ deleted = delete cache[key]; }
})
return deleted;
}
};
helpers.reportError = function() {
this.constructor.reportError.apply( this, arguments );
};
}());

@@ -326,3 +326,2 @@ var vows = require('vows')

debugger;
var actual = tpl( this.opts({ cache: true }) )

@@ -329,0 +328,0 @@

@@ -8,3 +8,3 @@ var vows = require('vows')

,program = require('commander')
,vash = require('../../build/vash')
,vash = require( path.join(__dirname, '..', '..', 'build', 'vash') )
,vruntime

@@ -43,4 +43,5 @@

var result = tpl.toString().match(/^function anonymous\(model,html,__vopts\)/g);
assert.equal( ( result || [''] )[0], 'function anonymous(model,html,__vopts)' )
var test = 'function anonymous(model,html,__vopts,vash)'
,result = tpl.toString().indexOf(test);
assert.strictEqual( result, 0, test )
}

@@ -61,4 +62,73 @@

}
,'.toClientString, vash.link loop disobeys thermodynamics': function( tpl ){
var client = tpl.toClientString() + '.toClientString()'
,actual = vm.runInNewContext( client, { vash: vruntime } );
assert.equal( actual, tpl.toClientString() );
}
}
,'installation': {
topic: ''
,'batched': function(){
var str =
'@vash.batch("div", function(){<div>@model</div>})'
+'@vash.batch("a", function(){<a>@model</a>})'
var tpl = vash.compile(str)
,model = 'm';
assert.equal( tpl(), '' );
assert.equal( vash.lookup('div')(model), '<div>m</div>' );
assert.equal( vash.lookup('a')(model), '<a>m</a>' );
}
,'vash.batch throws in standalone runtime': function(){
assert.throws(function(){
vm.runInNewContext( 'vash.batch()', { vash: vruntime } );
}, (/has no method ['"]batch['"]/g));
}
,'uninstalling removes': function(){
var str = '<p></p>'
,tpl = vash.compile(str);
vash.install('testpath', tpl);
assert.equal( vash.lookup('testpath')(), str );
vash.uninstall('testpath');
assert.throws( function(){
vash.lookup('testpath');
}, (/Could not find template: testpath/))
}
,'installing with string auto-compiles': function(){
var str = '<p></p>'
,tpl = vash.install('testpath', str);
assert.equal( tpl(), str );
}
,'installing with string throws if only runtime': function(){
var str = 'vash.install("testpath", "<p></p>")'
assert.throws(function(){
vm.runInNewContext( str, { vash: vruntime } );
}, (/not available/g));
}
,'lookup can execute with model': function(){
var str = '<p>@model.what</p>'
,tpl = vash.compile(str);
vash.install('testpath', tpl);
assert.equal( vash.lookup('testpath', { what: 'how' }), '<p>how</p>' );
vash.uninstall('testpath');
}
}
}).export(module)
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