velocityjs
Advanced tools
Comparing version 0.4.2 to 0.4.3
{ | ||
"name": "velocityjs", | ||
"description": "Velocity Template Language(VTL) for JavaScript", | ||
"version": "0.4.2", | ||
"version": "0.4.3", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "velocity template" |
@@ -112,11 +112,2 @@ module.exports = function(Velocity, utils){ | ||
//提前结束计算,某些情况下,连缀运行,后面的运算影响前面的结果,这种 | ||
//情况需要特殊处理,比如$control.setTempalte('a.vm').setParameter('a', 'b') | ||
//第一个函数就返回结果,这时候,函数返回对象为 | ||
//{$stop: true, $return: 'string'} | ||
//$stop表示停滞,$return:返回结果 | ||
if (ret === undefined || ret.$stop === true) { | ||
ret = ret && ret.$stop ? ret.$return : ret; | ||
return true; | ||
} | ||
}, this); | ||
@@ -308,3 +299,3 @@ } | ||
} | ||
}); | ||
}; | ||
}) | ||
} |
@@ -536,30 +536,18 @@ var Velocity = require('../src/velocity') | ||
setTemplate: function(str){ | ||
setTemplate: function(vm){ | ||
var $sys = this.$sys | ||
this.vm = vm; | ||
return this; | ||
if ($sys.others.length) { | ||
this.__temp = {} | ||
var ast = $sys.total | ||
ast.path = $sys.others | ||
$sys.vm.getReferences(ast) | ||
} | ||
return { | ||
$return: this.eval(str, this.__temp), | ||
$stop: true | ||
} | ||
}, | ||
toString: function(){ | ||
return this.eval(this.vm, this.__temp); | ||
}, | ||
__temp: {}, | ||
setParameter: function(key, value){ | ||
this.__temp[key] = value | ||
return this | ||
this.__temp[key] = value; | ||
return this; | ||
} | ||
}; | ||
} | ||
var str = 'hello $who, welcome to $where' | ||
@@ -566,0 +554,0 @@ |
423599
3873