velocityjs
Advanced tools
Comparing version 1.0.2 to 1.1.0
@@ -1,3 +0,12 @@ | ||
## 10.1 2018-03-08 | ||
## 1.1.0 2018-06-12 | ||
- feat: Add support for .put, fix issue [#103](https://github.com/shepherdwind/velocity.js/issues/103) by @lightsofapollo | ||
- feat: add config.valueMapper support by @lightsofapollo [#105](https://github.com/shepherdwind/velocity.js/pull/105) | ||
## 1.0.2 2018-06-06 | ||
- fix: ignore path where build on broswer, fix issue [#102](https://github.com/shepherdwind/velocity.js/issues/102) | ||
## 1.0.1 2018-03-08 | ||
- fix: #set bug in nested #foreach loops [#100](https://github.com/shepherdwind/velocity.js/issues/100) | ||
@@ -4,0 +13,0 @@ |
@@ -39,4 +39,6 @@ interface Velocity { | ||
interface CompileConfig { | ||
escape: boolean // escape variable | ||
unescape: { [varName: string]: boolean } // unescape var config | ||
escape?: boolean // escape variable | ||
unescape?: { [varName: string]: boolean } // unescape var config | ||
// @see https://github.com/shepherdwind/velocity.js/pull/105 | ||
valueMapper?: (value: any) => any | ||
} | ||
@@ -43,0 +45,0 @@ |
{ | ||
"name": "velocityjs", | ||
"description": "Velocity Template Language(VTL) for JavaScript", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -117,2 +117,3 @@ Velocity - Template Engine | ||
- env {string} when env equal `development` will throw error when null values are used | ||
- valueMapper {function} this config allow us to redefine the `#set` value, @see https://github.com/shepherdwind/velocity.js/pull/105 | ||
@@ -119,0 +120,0 @@ #### parse |
@@ -5,9 +5,14 @@ var utils = require('../utils'); | ||
this.asts = asts; | ||
this.config = { | ||
// 自动输出为经过html encode输出 | ||
escape: true, | ||
// 不需要转义的白名单 | ||
unescape: {} | ||
}; | ||
utils.mixin(this.config, config); | ||
this.config = utils.mixin( | ||
{ | ||
// 自动输出为经过html encode输出 | ||
escape: true, | ||
// 不需要转义的白名单 | ||
unescape: {}, | ||
valueMapper(value) { | ||
return value; | ||
}, | ||
}, | ||
config | ||
); | ||
this._state = { stop: false, break: false }; | ||
@@ -14,0 +19,0 @@ this.init(); |
@@ -268,3 +268,4 @@ module.exports = function(Velocity, utils) { | ||
return getSize(baseRef); | ||
} else if (id === 'put') { | ||
return baseRef[this.getLiteral(property.args[0])] = this.getLiteral(property.args[1]); | ||
} else { | ||
@@ -271,0 +272,0 @@ |
@@ -1,2 +0,2 @@ | ||
module.exports = function(Velocity, utils){ | ||
module.exports = function(Velocity, utils) { | ||
/** | ||
@@ -9,3 +9,3 @@ * 变量设置 | ||
*/ | ||
getContext: function(){ | ||
getContext: function() { | ||
var condition = this.condition; | ||
@@ -22,5 +22,5 @@ var local = this.local; | ||
*/ | ||
setValue: function(ast){ | ||
setValue: function(ast) { | ||
var ref = ast.equal[0]; | ||
var context = this.getContext(); | ||
var context = this.getContext(); | ||
@@ -41,3 +41,3 @@ // @see #25 | ||
} else { | ||
val = this.getLiteral(ast.equal[1]); | ||
val = this.config.valueMapper(this.getLiteral(ast.equal[1])); | ||
} | ||
@@ -60,5 +60,3 @@ | ||
const self = this; | ||
//console.log(val); | ||
utils.some(ref.path, function(exp, i){ | ||
utils.some(ref.path, function(exp, i) { | ||
var isEnd = len === i + 1; | ||
@@ -65,0 +63,0 @@ var key = exp.id; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
386215
2772
152