Socket
Socket
Sign inDemoInstall

velocityjs

Package Overview
Dependencies
0
Maintainers
1
Versions
76
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.4.8 to 0.4.9

5

History.md

@@ -12,1 +12,6 @@ ## 0.4

- merge pull request #34
### 0.4.9 / 2014-12-29
- feature: support friendly error stack #35
- chore: improve coverage

6

package.json
{
"name": "velocityjs",
"description": "Velocity Template Language(VTL) for JavaScript",
"version": "0.4.8",
"version": "0.4.9",
"keywords": [

@@ -21,5 +21,7 @@ "velocity template"

"devDependencies": {
"coveralls": "~2.11.2",
"istanbul": "~0.3.5",
"jison": ">=0.3",
"mocha": ">=1.7.2"
"mocha": ">=1.7.2",
"mocha-lcov-reporter": "0.0.1"
},

@@ -26,0 +28,0 @@ "scripts": {

@@ -1,4 +0,5 @@

Velocity - Template Engine
Velocity - Template Engine
==========================
[![Build Status](https://secure.travis-ci.org/shepherdwind/velocity.js.png)](https://travis-ci.org/shepherdwind/velocity.js)
[![Coverage Status](https://img.shields.io/coveralls/shepherdwind/velocity.js/master.svg?style=flat)](https://coveralls.io/r/shepherdwind/velocity.js)

@@ -5,0 +6,0 @@ [![NPM](https://nodei.co/npm/velocityjs.png?downloads=true)](https://nodei.co/npm/velocityjs/)

@@ -15,12 +15,20 @@ module.exports = function(Velocity, utils){

if (ast.type === 'if') {
ret = this.getBlockIf(block);
} else if (ast.type === 'foreach') {
ret = this.getBlockEach(block);
} else if (ast.type === 'macro') {
this.setBlockMacro(block);
} else if (ast.type === 'noescape') {
ret = this._render(block.slice(1));
} else {
ret = this._render(block);
switch (ast.type) {
case 'if':
ret = this.getBlockIf(block);
break;
case 'foreach':
ret = this.getBlockEach(block);
break;
case 'macro':
this.setBlockMacro(block);
break;
case 'noescape':
ret = this._render(block.slice(1));
break;
case 'define':
this.setBlockDefine(block);
break;
default:
ret = this._render(block);
}

@@ -32,2 +40,13 @@

/**
* define
*/
setBlockDefine: function(block){
var ast = block[0];
var _block = block.slice(1);
var defines = this.defines;
defines[ast.id] = _block;
},
/**
* define macro

@@ -65,3 +84,13 @@ */

ret = macro.apply(this, jsArgs);
try {
ret = macro.apply(this, jsArgs);
} catch(e){
var pos = ast.pos;
var text = Velocity.Helper.getRefText(ast);
// throws error tree
var err = '\n at ' + text + ' L/N ' + pos.first_line + ':' + pos.first_column;
e.name = '';
e.message += err;
throw new Error(e);
}

@@ -68,0 +97,0 @@ }

@@ -10,2 +10,3 @@ module.exports = function(Velocity, utils){

this.macros = {};
this.defines = {};
this.conditions = [];

@@ -12,0 +13,0 @@ this.local = {};

module.exports = function(Velocity, utils){
'use strict'
'use strict';

@@ -76,3 +76,7 @@ function getSize(obj){

if (ast.prue) {
if (ast.id in this.config.unescape) ast.prue = false
var define = this.defines[ast.id];
if (utils.isArray(define)) {
return this._render(define);
}
if (ast.id in this.config.unescape) ast.prue = false;
}

@@ -87,3 +91,3 @@ var escape = this.config.escape;

var text = Velocity.Helper.getRefText(ast)
var text = Velocity.Helper.getRefText(ast);

@@ -96,3 +100,3 @@ if (text in context) {

if (ret !== undefined && isfn) {
ret = this.getPropMethod(ast, context);
ret = this.getPropMethod(ast, context, ast);
}

@@ -104,6 +108,6 @@

utils.some(ast.path, function(property, i){
utils.some(ast.path, function(property){
//第三个参数,返回后面的参数ast
ret = this.getAttributes(property, ret);
ret = this.getAttributes(property, ret, ast);

@@ -117,3 +121,3 @@ }, this);

ret = (ast.prue && escape) ? convert(ret) : ret
ret = (ast.prue && escape) ? convert(ret) : ret;

@@ -154,3 +158,3 @@ return ret;

*/
getAttributes: function(property, baseRef){
getAttributes: function(property, baseRef, ast){
/**

@@ -163,3 +167,3 @@ * type对应着velocity.yy中的attribute,三种类型: method, index, property

if (type === 'method'){
ret = this.getPropMethod(property, baseRef);
ret = this.getPropMethod(property, baseRef, ast);
} else if (type === 'property') {

@@ -194,3 +198,3 @@ ret = baseRef[id];

*/
getPropMethod: function(property, baseRef){
getPropMethod: function(property, baseRef, ast){

@@ -261,4 +265,14 @@ var id = property.id;

};
ret = ret.apply(baseRef, args);
try {
ret = ret.apply(baseRef, args);
} catch(e) {
var pos = ast.pos;
var text = Velocity.Helper.getRefText(ast);
var err = ' on ' + text + ' at L/N ' + pos.first_line + ':' + pos.first_column;
e.name = '';
e.message += err;
throw new Error(e);
}
} else {

@@ -265,0 +279,0 @@ ret = undefined;

@@ -10,2 +10,6 @@ module.exports = function(Helper, utils){

if (ast.type === 'macro_call') {
ret = '#';
}
if (ast.isWraped) ret += '{';

@@ -12,0 +16,0 @@

@@ -75,3 +75,3 @@ /* parser generated by jison 0.4.15 */

var parser = (function(){
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,8],$V1=[1,18],$V2=[1,9],$V3=[1,22],$V4=[1,21],$V5=[4,10,19,33,34,79],$V6=[1,26],$V7=[1,30],$V8=[1,31],$V9=[1,32],$Va=[1,33],$Vb=[4,10,19,22,33,34,44,45,46,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,91],$Vc=[1,49],$Vd=[1,54],$Ve=[1,55],$Vf=[1,80],$Vg=[1,91],$Vh=[1,83],$Vi=[1,81],$Vj=[1,86],$Vk=[1,90],$Vl=[1,87],$Vm=[1,88],$Vn=[4,10,19,22,33,34,44,45,46,49,50,51,52,53,54,55,56,57,58,59,60,61,71,72,77,79,80,81,91],$Vo=[1,118],$Vp=[1,114],$Vq=[1,115],$Vr=[1,126],$Vs=[22,45,81],$Vt=[2,89],$Vu=[22,44,45,72,81],$Vv=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81],$Vw=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,93],$Vx=[2,102],$Vy=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,91],$Vz=[2,105],$VA=[1,135],$VB=[1,141],$VC=[22,44,45],$VD=[1,146],$VE=[1,147],$VF=[1,148],$VG=[1,149],$VH=[1,150],$VI=[1,151],$VJ=[1,152],$VK=[1,153],$VL=[1,154],$VM=[1,155],$VN=[1,156],$VO=[1,157],$VP=[1,158],$VQ=[22,49,50,51,52,53,54,55,56,57,58,59,60,61],$VR=[45,81],$VS=[2,106],$VT=[22,33],$VU=[1,205],$VV=[1,204],$VW=[45,72],$VX=[22,49,50],$VY=[22,49,50,51,52,56,57,58,59,60,61],$VZ=[22,49,50,56,57,58,59,60,61];
var o=function(k,v,o,l){for(o=o||{},l=k.length;l--;o[k[l]]=v);return o},$V0=[1,8],$V1=[1,18],$V2=[1,9],$V3=[1,22],$V4=[1,21],$V5=[4,10,19,33,34,79],$V6=[1,26],$V7=[1,29],$V8=[1,30],$V9=[4,10,19,22,33,34,44,45,46,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,91],$Va=[1,46],$Vb=[1,51],$Vc=[1,52],$Vd=[1,66],$Ve=[1,67],$Vf=[1,78],$Vg=[1,89],$Vh=[1,81],$Vi=[1,79],$Vj=[1,84],$Vk=[1,88],$Vl=[1,85],$Vm=[1,86],$Vn=[4,10,19,22,33,34,44,45,46,49,50,51,52,53,54,55,56,57,58,59,60,61,71,72,77,79,80,81,91],$Vo=[1,115],$Vp=[1,111],$Vq=[1,112],$Vr=[1,123],$Vs=[22,45,81],$Vt=[2,89],$Vu=[22,44,45,72,81],$Vv=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81],$Vw=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,93],$Vx=[2,102],$Vy=[22,44,45,49,50,51,52,53,54,55,56,57,58,59,60,61,72,79,81,91],$Vz=[2,105],$VA=[1,132],$VB=[1,138],$VC=[22,44,45],$VD=[1,143],$VE=[1,144],$VF=[1,145],$VG=[1,146],$VH=[1,147],$VI=[1,148],$VJ=[1,149],$VK=[1,150],$VL=[1,151],$VM=[1,152],$VN=[1,153],$VO=[1,154],$VP=[1,155],$VQ=[22,49,50,51,52,53,54,55,56,57,58,59,60,61],$VR=[45,81],$VS=[2,106],$VT=[22,33],$VU=[1,202],$VV=[1,201],$VW=[45,72],$VX=[22,49,50],$VY=[22,49,50,51,52,56,57,58,59,60,61],$VZ=[22,49,50,56,57,58,59,60,61];
var parser = {trace: function trace() { },

@@ -100,5 +100,8 @@ yy: {},

case 5:
$$[$0]['prue'] = true; this.$ = $$[$0];
$$[$0]['prue'] = true; $$[$0].pos = this._$; this.$ = $$[$0];
break;
case 6: case 7: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 18: case 19: case 41: case 42: case 46: case 47: case 48: case 62: case 65: case 66: case 76: case 77: case 78: case 79: case 85: case 92: case 99: case 100: case 105: case 111: case 113: case 126: case 127:
case 6:
$$[$0].pos = this._$; this.$ = $$[$0];
break;
case 7: case 9: case 10: case 11: case 12: case 13: case 14: case 15: case 16: case 18: case 19: case 41: case 42: case 46: case 47: case 48: case 62: case 65: case 66: case 76: case 77: case 78: case 79: case 85: case 92: case 99: case 100: case 105: case 111: case 113: case 126: case 127:
this.$ = $$[$0];

@@ -276,4 +279,4 @@ break;

},
table: [{3:1,4:[1,2],5:3,6:4,7:5,8:6,9:7,10:$V0,11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:$V1,23:19,24:20,33:$V2,34:$V3,79:$V4},{1:[3]},{1:[2,1]},{4:[1,23],6:24,7:5,8:6,9:7,10:$V0,11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:$V1,23:19,24:20,33:$V2,34:$V3,79:$V4},o($V5,[2,3]),o($V5,[2,5]),o($V5,[2,6]),o($V5,[2,7]),o($V5,[2,8]),{34:$V6,65:25,67:28,68:27,69:$V7,70:$V8,71:$V9,72:$Va,79:[1,29]},o($V5,[2,9]),o($V5,[2,10]),o($V5,[2,11]),o($V5,[2,12]),o($V5,[2,13]),o($V5,[2,14]),o($V5,[2,15]),o($V5,[2,16]),{20:[1,34],25:[1,37],27:[1,38],29:[1,39],30:[1,40],31:[1,41],32:[1,42],34:[1,36],37:[1,43],38:[1,44],39:[1,45],79:[1,35]},o($V5,[2,18]),o($V5,[2,19]),o($V5,[2,126]),o($V5,[2,127]),{1:[2,2]},o($V5,[2,4]),{34:[1,46],68:47},o($Vb,[2,72],{66:48,73:50,74:51,75:52,76:53,21:$Vc,77:$Vd,80:$Ve}),o($Vb,[2,74],{73:50,74:51,75:52,76:53,66:56,77:$Vd,80:$Ve}),{34:[1,58],68:57},o($V5,[2,131]),{34:[2,76]},{34:[2,77]},o($Vb,[2,78]),o($Vb,[2,79]),{21:[1,59]},o($V5,[2,128]),{4:[1,61],21:[1,62],79:[1,60]},{21:[1,63]},{21:[1,64]},{21:[1,65]},o($V5,[2,23]),o($V5,[2,24]),{21:[1,66]},o($V5,[2,27]),{21:[1,67]},{21:[1,68]},{21:$Vc,66:69,67:70,71:$V9,72:$Va,73:50,74:51,75:52,76:53,77:$Vd,80:$Ve},{66:71,73:50,74:51,75:52,76:53,77:$Vd,80:$Ve},o($Vb,[2,69],{74:51,75:52,76:53,73:72,77:$Vd,80:$Ve}),{7:76,22:[1,74],33:$Vf,36:77,43:75,47:78,52:$Vg,64:79,70:$Vh,78:73,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},o($Vn,[2,80]),o($Vn,[2,82]),o($Vn,[2,83]),o($Vn,[2,84]),{34:[1,93],68:92,79:[1,94]},{7:96,33:$Vf,52:$Vg,64:95,79:[1,97],81:[1,98],82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},o($Vb,[2,71],{74:51,75:52,76:53,73:72,77:$Vd,80:$Ve}),{67:99,71:$V9,72:$Va},{21:$Vc},{22:[1,100]},o($V5,[2,129]),o($V5,[2,130]),{7:106,22:[1,102],33:$Vf,36:77,41:101,42:103,43:105,44:[1,104],47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{7:108,26:107,33:$Vf},{7:116,21:$Vo,28:109,33:$Vf,36:110,47:111,48:112,52:$Vp,62:113,63:$Vq,64:117,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{7:116,21:$Vo,28:119,33:$Vf,36:110,47:111,48:112,52:$Vp,62:113,63:$Vq,64:117,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{33:[1,120]},{33:[1,121]},{34:[1,122]},{67:123,71:$V9,72:$Va,73:72,74:51,75:52,76:53,77:$Vd,80:$Ve},o($Vb,[2,73]),{67:124,71:$V9,72:$Va,73:72,74:51,75:52,76:53,77:$Vd,80:$Ve},o($Vn,[2,81]),{22:[1,125],45:$Vr},o($Vn,[2,87]),o($Vs,[2,88]),o([22,45],$Vt),o($Vu,[2,109]),o($Vu,[2,110]),o($Vu,[2,111]),{34:$V6,65:25,67:28,68:27,69:$V7,70:$V8,71:$V9,72:$Va},{7:130,33:$Vf,36:77,43:75,47:78,52:$Vg,64:79,70:$Vh,78:127,80:$Vi,81:[1,128],82:84,83:85,84:$Vj,85:129,86:$Vk,88:$Vl,89:$Vm,90:82},o($Vu,[2,113]),{72:[1,132],82:133,88:$Vl,89:$Vm,92:131},o($Vv,[2,99]),o($Vv,[2,100]),o($Vv,[2,101]),o($Vw,[2,107]),o($Vw,[2,108]),o($Vv,$Vx),o($Vy,$Vz,{87:[1,134]}),{86:$VA},o($Vn,[2,85]),o($Vn,[2,92],{21:$Vc}),o($Vn,[2,93]),{79:[1,137],81:[1,136]},{81:[1,138]},o($Vn,[2,97]),o($Vn,[2,98]),o($Vb,[2,75]),o($V5,[2,17]),{22:[1,139]},o($V5,[2,34]),{22:[2,41],44:[1,140],45:$VB},{7:106,33:$Vf,36:77,42:142,43:105,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},o($VC,[2,35]),o($VC,[2,36]),{22:[1,143]},{46:[1,144]},{22:[1,145]},{22:[2,46]},{22:[2,47]},{22:[2,48],49:$VD,50:$VE,51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP},o($VQ,[2,62]),{21:$Vo,62:159,86:$VA},{7:116,21:$Vo,33:$Vf,48:160,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},o($VQ,[2,65]),o($VQ,[2,66]),{7:116,21:$Vo,33:$Vf,48:161,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{22:[1,162]},{34:[1,163]},{34:[1,164]},{7:167,22:[1,166],33:$Vf,40:165},o($Vb,[2,68]),o($Vb,[2,70]),o($Vn,[2,86]),{7:169,33:$Vf,36:77,43:168,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{45:$Vr,81:[1,170]},o($Vu,[2,114]),o($VR,$Vx,{91:[1,171]}),o($VR,$Vt,{91:[1,172]}),{45:[1,174],72:[1,173]},o($Vu,[2,120]),{93:[1,175]},{86:[1,176]},o($Vy,$VS,{87:[1,177]}),o($Vn,[2,94]),o($Vn,[2,96]),o($Vn,[2,95]),o($V5,[2,33]),{7:179,22:[2,44],33:$Vf,36:77,43:178,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{7:181,33:$Vf,36:77,43:180,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{22:[2,42],44:[1,182],45:$VB},o($V5,[2,20]),{7:116,21:$Vo,28:183,33:$Vf,36:110,47:111,48:112,52:$Vp,62:113,63:$Vq,64:117,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},o($V5,[2,21]),{7:116,21:$Vo,33:$Vf,48:184,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:185,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:186,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:187,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:188,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:189,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:190,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:191,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:192,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:193,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:194,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:195,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},{7:116,21:$Vo,33:$Vf,48:196,52:$Vp,62:113,63:$Vq,64:117,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm},o($VQ,[2,63]),o($VQ,[2,64]),{22:[1,197],49:$VD,50:$VE,51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP},o($V5,[2,22]),{35:[1,198]},{22:[1,199]},{7:201,22:[1,200],33:$Vf},o($V5,[2,30]),o($VT,[2,31]),o($Vs,[2,90]),o($Vs,[2,91]),o($Vu,[2,112]),{7:203,33:$Vf,52:$VU,85:202,86:$VV},{7:207,33:$Vf,52:$VU,85:206,86:$VV},o($Vu,[2,119]),{82:208,88:$Vl,89:$Vm},o($VW,[2,123],{36:77,47:78,64:79,90:82,82:84,83:85,85:89,43:209,7:210,33:$Vf,52:$Vg,70:$Vh,80:$Vi,84:$Vj,86:$Vk,88:$Vl,89:$Vm}),o($Vv,[2,103]),{86:[1,211]},o($VC,[2,37]),o($VC,[2,40]),o($VC,[2,38]),o($VC,[2,39]),{7:179,22:[2,43],33:$Vf,36:77,43:178,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},{22:[2,45]},o($VX,[2,49],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP}),o($VX,[2,50],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP}),o($VY,[2,51],{53:$VH,54:$VI,55:$VJ}),o($VY,[2,52],{53:$VH,54:$VI,55:$VJ}),o($VQ,[2,53]),o($VQ,[2,54]),o($VQ,[2,55]),o($VZ,[2,56],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,57],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,58],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,59],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,60],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,61],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VQ,[2,67]),{7:212,33:$Vf,36:213,80:$Vi,90:82},o($V5,[2,28]),o($V5,[2,29]),o($VT,[2,32]),{81:[1,214]},{81:[1,215]},{81:$Vz},{86:[1,216]},{81:[1,217]},{81:[1,218]},{93:[1,219]},o($VW,[2,121]),o($VW,[2,122]),o($Vv,[2,104]),{22:[1,220]},{22:[1,221]},o($Vu,[2,115]),o($Vu,[2,117]),{81:$VS},o($Vu,[2,116]),o($Vu,[2,118]),{7:222,33:$Vf,36:77,43:223,47:78,52:$Vg,64:79,70:$Vh,80:$Vi,82:84,83:85,84:$Vj,85:89,86:$Vk,88:$Vl,89:$Vm,90:82},o($V5,[2,25]),o($V5,[2,26]),o($VW,[2,124]),o($VW,[2,125])],
defaultActions: {2:[2,1],23:[2,2],30:[2,76],31:[2,77],110:[2,46],111:[2,47],183:[2,45],204:[2,105],216:[2,106]},
table: [{3:1,4:[1,2],5:3,6:4,7:5,8:6,9:7,10:$V0,11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:$V1,23:19,24:20,33:$V2,34:$V3,79:$V4},{1:[3]},{1:[2,1]},{4:[1,23],6:24,7:5,8:6,9:7,10:$V0,11:10,12:11,13:12,14:13,15:14,16:15,17:16,18:17,19:$V1,23:19,24:20,33:$V2,34:$V3,79:$V4},o($V5,[2,3]),o($V5,[2,5]),o($V5,[2,6]),o($V5,[2,7]),o($V5,[2,8]),{34:$V6,65:25,68:27,69:$V7,70:$V8,79:[1,28]},o($V5,[2,9]),o($V5,[2,10]),o($V5,[2,11]),o($V5,[2,12]),o($V5,[2,13]),o($V5,[2,14]),o($V5,[2,15]),o($V5,[2,16]),{20:[1,31],25:[1,34],27:[1,35],29:[1,36],30:[1,37],31:[1,38],32:[1,39],34:[1,33],37:[1,40],38:[1,41],39:[1,42],79:[1,32]},o($V5,[2,18]),o($V5,[2,19]),o($V5,[2,126]),o($V5,[2,127]),{1:[2,2]},o($V5,[2,4]),{34:[1,43],68:44},o($V9,[2,72],{66:45,73:47,74:48,75:49,76:50,21:$Va,77:$Vb,80:$Vc}),o($V9,[2,74],{73:47,74:48,75:49,76:50,66:53,77:$Vb,80:$Vc}),o($V5,[2,131]),{34:[2,76]},{34:[2,77]},{21:[1,54]},o($V5,[2,128]),{4:[1,56],21:[1,57],79:[1,55]},{21:[1,58]},{21:[1,59]},{21:[1,60]},o($V5,[2,23]),o($V5,[2,24]),{21:[1,61]},o($V5,[2,27]),{21:[1,62]},{21:[1,63]},{21:$Va,66:64,67:65,71:$Vd,72:$Ve,73:47,74:48,75:49,76:50,77:$Vb,80:$Vc},{66:68,67:69,71:$Vd,72:$Ve,73:47,74:48,75:49,76:50,77:$Vb,80:$Vc},o($V9,[2,69],{74:48,75:49,76:50,73:70,77:$Vb,80:$Vc}),{7:74,22:[1,72],33:$Vf,36:75,43:73,47:76,52:$Vg,64:77,70:$Vh,78:71,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},o($Vn,[2,80]),o($Vn,[2,82]),o($Vn,[2,83]),o($Vn,[2,84]),{34:[1,91],68:90,79:[1,92]},{7:94,33:$Vf,52:$Vg,64:93,79:[1,95],81:[1,96],82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},o($V9,[2,71],{74:48,75:49,76:50,73:70,77:$Vb,80:$Vc}),{22:[1,97]},o($V5,[2,129]),o($V5,[2,130]),{7:103,22:[1,99],33:$Vf,36:75,41:98,42:100,43:102,44:[1,101],47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{7:105,26:104,33:$Vf},{7:113,21:$Vo,28:106,33:$Vf,36:107,47:108,48:109,52:$Vp,62:110,63:$Vq,64:114,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{7:113,21:$Vo,28:116,33:$Vf,36:107,47:108,48:109,52:$Vp,62:110,63:$Vq,64:114,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{33:[1,117]},{33:[1,118]},{34:[1,119]},{67:120,71:$Vd,72:$Ve,73:70,74:48,75:49,76:50,77:$Vb,80:$Vc},o($V9,[2,73]),o($V9,[2,78]),o($V9,[2,79]),{67:121,71:$Vd,72:$Ve,73:70,74:48,75:49,76:50,77:$Vb,80:$Vc},o($V9,[2,75]),o($Vn,[2,81]),{22:[1,122],45:$Vr},o($Vn,[2,87]),o($Vs,[2,88]),o([22,45],$Vt),o($Vu,[2,109]),o($Vu,[2,110]),o($Vu,[2,111]),{34:$V6,65:25,68:27,69:$V7,70:$V8},{7:127,33:$Vf,36:75,43:73,47:76,52:$Vg,64:77,70:$Vh,78:124,80:$Vi,81:[1,125],82:82,83:83,84:$Vj,85:126,86:$Vk,88:$Vl,89:$Vm,90:80},o($Vu,[2,113]),{72:[1,129],82:130,88:$Vl,89:$Vm,92:128},o($Vv,[2,99]),o($Vv,[2,100]),o($Vv,[2,101]),o($Vw,[2,107]),o($Vw,[2,108]),o($Vv,$Vx),o($Vy,$Vz,{87:[1,131]}),{86:$VA},o($Vn,[2,85]),o($Vn,[2,92],{21:$Va}),o($Vn,[2,93]),{79:[1,134],81:[1,133]},{81:[1,135]},o($Vn,[2,97]),o($Vn,[2,98]),o($V5,[2,17]),{22:[1,136]},o($V5,[2,34]),{22:[2,41],44:[1,137],45:$VB},{7:103,33:$Vf,36:75,42:139,43:102,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},o($VC,[2,35]),o($VC,[2,36]),{22:[1,140]},{46:[1,141]},{22:[1,142]},{22:[2,46]},{22:[2,47]},{22:[2,48],49:$VD,50:$VE,51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP},o($VQ,[2,62]),{21:$Vo,62:156,86:$VA},{7:113,21:$Vo,33:$Vf,48:157,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},o($VQ,[2,65]),o($VQ,[2,66]),{7:113,21:$Vo,33:$Vf,48:158,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{22:[1,159]},{34:[1,160]},{34:[1,161]},{7:164,22:[1,163],33:$Vf,40:162},o($V9,[2,68]),o($V9,[2,70]),o($Vn,[2,86]),{7:166,33:$Vf,36:75,43:165,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{45:$Vr,81:[1,167]},o($Vu,[2,114]),o($VR,$Vx,{91:[1,168]}),o($VR,$Vt,{91:[1,169]}),{45:[1,171],72:[1,170]},o($Vu,[2,120]),{93:[1,172]},{86:[1,173]},o($Vy,$VS,{87:[1,174]}),o($Vn,[2,94]),o($Vn,[2,96]),o($Vn,[2,95]),o($V5,[2,33]),{7:176,22:[2,44],33:$Vf,36:75,43:175,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{7:178,33:$Vf,36:75,43:177,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{22:[2,42],44:[1,179],45:$VB},o($V5,[2,20]),{7:113,21:$Vo,28:180,33:$Vf,36:107,47:108,48:109,52:$Vp,62:110,63:$Vq,64:114,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},o($V5,[2,21]),{7:113,21:$Vo,33:$Vf,48:181,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:182,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:183,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:184,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:185,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:186,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:187,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:188,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:189,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:190,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:191,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:192,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},{7:113,21:$Vo,33:$Vf,48:193,52:$Vp,62:110,63:$Vq,64:114,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm},o($VQ,[2,63]),o($VQ,[2,64]),{22:[1,194],49:$VD,50:$VE,51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP},o($V5,[2,22]),{35:[1,195]},{22:[1,196]},{7:198,22:[1,197],33:$Vf},o($V5,[2,30]),o($VT,[2,31]),o($Vs,[2,90]),o($Vs,[2,91]),o($Vu,[2,112]),{7:200,33:$Vf,52:$VU,85:199,86:$VV},{7:204,33:$Vf,52:$VU,85:203,86:$VV},o($Vu,[2,119]),{82:205,88:$Vl,89:$Vm},o($VW,[2,123],{36:75,47:76,64:77,90:80,82:82,83:83,85:87,43:206,7:207,33:$Vf,52:$Vg,70:$Vh,80:$Vi,84:$Vj,86:$Vk,88:$Vl,89:$Vm}),o($Vv,[2,103]),{86:[1,208]},o($VC,[2,37]),o($VC,[2,40]),o($VC,[2,38]),o($VC,[2,39]),{7:176,22:[2,43],33:$Vf,36:75,43:175,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},{22:[2,45]},o($VX,[2,49],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP}),o($VX,[2,50],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ,56:$VK,57:$VL,58:$VM,59:$VN,60:$VO,61:$VP}),o($VY,[2,51],{53:$VH,54:$VI,55:$VJ}),o($VY,[2,52],{53:$VH,54:$VI,55:$VJ}),o($VQ,[2,53]),o($VQ,[2,54]),o($VQ,[2,55]),o($VZ,[2,56],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,57],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,58],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,59],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,60],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VZ,[2,61],{51:$VF,52:$VG,53:$VH,54:$VI,55:$VJ}),o($VQ,[2,67]),{7:209,33:$Vf,36:210,80:$Vi,90:80},o($V5,[2,28]),o($V5,[2,29]),o($VT,[2,32]),{81:[1,211]},{81:[1,212]},{81:$Vz},{86:[1,213]},{81:[1,214]},{81:[1,215]},{93:[1,216]},o($VW,[2,121]),o($VW,[2,122]),o($Vv,[2,104]),{22:[1,217]},{22:[1,218]},o($Vu,[2,115]),o($Vu,[2,117]),{81:$VS},o($Vu,[2,116]),o($Vu,[2,118]),{7:219,33:$Vf,36:75,43:220,47:76,52:$Vg,64:77,70:$Vh,80:$Vi,82:82,83:83,84:$Vj,85:87,86:$Vk,88:$Vl,89:$Vm,90:80},o($V5,[2,25]),o($V5,[2,26]),o($VW,[2,124]),o($VW,[2,125])],
defaultActions: {2:[2,1],23:[2,2],29:[2,76],30:[2,77],107:[2,46],108:[2,47],180:[2,45],201:[2,105],213:[2,106]},
parseError: function parseError(str, hash) {

@@ -838,6 +841,5 @@ if (hash.recoverable) {

break;
case 31:
var conditionStack = this.conditionStack;
var len = conditionStack.length;
if (len >= 2 && conditionStack[len - 1] === 'c' && conditionStack[len - 2] === 'run') {
case 31:
var len = this.stateStackSize();
if (len >= 2 && this.topState() === 'c' && this.topState(1) === 'run') {
return 44;

@@ -861,8 +863,7 @@ }

break;
case 39:
case 39:
if (this.popState() === "c") {
var conditionStack = this.conditionStack;
var len = conditionStack.length;
var len = this.stateStackSize();
if (conditionStack[len - 1] === 'run') {
if (this.topState() === 'run') {
this.popState();

@@ -872,6 +873,7 @@ len = len - 1;

var tailStack = this.topState(len - 2);
/** 遇到#set(a = b)括号结束后结束状态h*/
if (len === 2 && conditionStack[1] === "h"){
if (len === 2 && tailStack === "h"){
this.popState();
} else if (len === 3 && conditionStack[1] === "mu" && conditionStack[2] === "h") {
} else if (len === 3 && tailStack === "mu" && this.topState(len - 3) === "h") {
// issue#7 $foo#if($a)...#end

@@ -878,0 +880,0 @@ this.popState();

@@ -55,3 +55,10 @@ "use strict";

var blockTypes = {'if': 1, 'foreach': 1, 'macro': 1, 'noescape': 1, 'define': 1};
var blockTypes = {
'if': 1,
'foreach': 1,
'macro': 1,
'noescape': 1,
'define': 1
};
var len = block.length;

@@ -58,0 +65,0 @@ index = index || 0;

@@ -26,2 +26,17 @@ var Velocity = require('../src/velocity')

it('method with attribute', function(){
var vm = '$foo().bar\n${foo().bar}'
assert.equal('hello\nhello', render(vm, {
foo: function(){
return { bar: 'hello' }
}
}))
assert.equal('foo', render('${foo()}', {
foo: function(){
return 'foo'
}
}))
})
it('index notation', function(){

@@ -486,2 +501,4 @@ var vm = '$foo[0] $foo[$i] $foo.get(1)'

assert.equal('', render(''))
assert.equal('', render('##hello'))
assert.equal('hello', render('hello'))
})

@@ -491,4 +508,53 @@

describe('self defined macro', function(){
describe('throw friendly error message', function() {
it('print right posiont when error throw', function(){
var vm = '111\nsdfs\n$foo($name)'
var expected = '<i>'
var compile = new Compile(Parser.parse(vm), { escape: false })
var context = {
name: '<i>',
foo: function(name){
throw new Error('Run error')
}
}
assert.throws(function(){
compile.render(context)
}, /\$foo\(\$name\)/)
assert.throws(function(){
compile.render(context)
}, /L\/N 3:0/)
})
it('print error stack of user-defined macro', function(){
var vm = '111\n\n#foo($name)'
var vm1 = '\nhello#parse("vm.vm")'
var files = { 'vm.vm': vm, 'vm1.vm': vm1 };
var compile = new Compile(Parser.parse('\n\n#parse("vm1.vm")'))
var macros = {
foo: function(name){
throw new Error('Run error')
},
parse: function(name){
return this.eval(files[name]);
}
}
var expected = '' +
'Run error\n' +
' at #foo($name) L/N 3:0\n' +
' at #parse("vm.vm") L/N 2:5\n' +
' at #parse("vm1.vm") L/N 3:0';
try {
compile.render({}, macros)
} catch(e) {
assert.equal(expected, e.message);
}
})
})
describe('user-defined macro, such as #include, #parse', function(){
it('basic', function(){

@@ -666,9 +732,16 @@ var macros = {

})
it('multiple newlines after statement', function(){
var vm = '#if(1>0)\n\nb#end'
assert.equal('\nb', render(vm))
})
})
it('multiple newlines after statement', function(){
var vm = '#if(1>0)\n\nb#end'
assert.equal('\nb', render(vm))
describe('define support', function(){
it('basic', function(){
var vm = '#define( $block )\nHello $who#end\n#set( $who = "World!" )\n$block'
assert.equal('Hello World!', render(vm))
})
})
})
})

@@ -49,3 +49,4 @@ var Parser = require('../src/velocity').Parser

path : [{"type": "property","id": "Address"}],
leader : '$'
leader : '$',
pos: { first_line: 1, last_line: 1, first_column: 0, last_column: 17 }
})

@@ -52,0 +53,0 @@ })

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc