Skip to content

Commit

Permalink
chore: update version, add add some comment
Browse files Browse the repository at this point in the history
  • Loading branch information
shepherdwind committed Aug 27, 2019
1 parent 9ddb4d7 commit 223ec38
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 19 deletions.
4 changes: 4 additions & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 1.1.4 2019-08-27

- Added support for remove in ArrayList and Map @mdrewt [#124](https://github.com/shepherdwind/velocity.js/pull/124)

## 1.1.3 2018-09-18

- fixes issue#113 support for add method on arrays by @gauravlanjekar [#114](https://github.com/shepherdwind/velocity.js/pull/114/)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "velocityjs",
"description": "Velocity Template Language(VTL) for JavaScript",
"version": "1.1.3",
"version": "1.1.4",
"license": "MIT",
"keywords": [
"velocity template"
Expand Down
15 changes: 7 additions & 8 deletions src/compile/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,10 @@
module.exports = function(Velocity, utils) {

/**
* blocks语法处理
* blocks such as if, foreach, macro syntax handler
*/
utils.mixin(Velocity.prototype, {
/**
* 处理代码库: if foreach macro
*/

getBlock: function(block) {

var ast = block[0];
Expand Down Expand Up @@ -93,6 +91,7 @@ module.exports = function(Velocity, utils) {
var self = this;

// bug修复:此处由于闭包特性,导致eval函数执行时的this对象是上一次函数执行时的this对象,渲染时上下文发生错误。
// js macros export evel function
jsmacros.eval = function() {
return self.eval.apply(self, arguments);
};
Expand Down Expand Up @@ -136,9 +135,9 @@ module.exports = function(Velocity, utils) {

/**
* eval
* @param str {array|string} 需要解析的字符串
* @param local {object} 局部变量
* @param contextId {string}
* @param str {array|string} input string
* @param local {object} local variable
* @param contextId {=string} optional contextId, this contextId use to find local variable
* @return {string}
*/
eval: function(str, local, contextId) {
Expand Down Expand Up @@ -211,7 +210,7 @@ module.exports = function(Velocity, utils) {
if (this._state.break) {
return;
}
// 构造临时变量
// for each local variable
local[_to] = val;
local.foreach = {
count: i + 1,
Expand Down
2 changes: 1 addition & 1 deletion src/compile/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = function(Velocity, utils) {
},

/**
* @param context {object} 上下文环境,数据对象
* @param context {object} context object
* @param macro {object} self defined #macro
* @param silent {bool} 如果是true,$foo变量将原样输出
* @return str
Expand Down
2 changes: 1 addition & 1 deletion src/compile/expression.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module.exports = function(Velocity, utils){
/**
* expression运算
* expression support, include math, logic, compare expression
*/
utils.mixin(Velocity.prototype, {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/compile/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function Velocity(asts, config) {
this.asts = asts;
this.config = utils.mixin(
{
// 自动输出为经过html encode输出
// 自动输出为经过html e输出
escape: true,
// 不需要转义的白名单
unescape: {},
Expand Down
4 changes: 2 additions & 2 deletions src/compile/literal.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
'use strict';
module.exports = function(Velocity, utils) {
/**
* literal解释模块
* literal parse, include string, integer, array, map, bool data structure
* @require {method} getReferences
*/
utils.mixin(Velocity.prototype, {
/**
* 字面量求值,主要包括string, integer, array, map四种数据结构
* @param literal {object} 定义于velocity.yy文件,type描述数据类型,value属性
* 是literal值描述
* @return {object|string|number|array}返回对应的js变量
* @return {object|string|number|array} js variable
*/
getLiteral: function(literal) {

Expand Down
2 changes: 1 addition & 1 deletion src/compile/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ module.exports = function(Velocity, utils) {
}

/**
* unicode转码
* unicode encode
*/
function convert(str) {

Expand Down
4 changes: 2 additions & 2 deletions src/compile/set.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
module.exports = function(Velocity, utils) {
/**
* 变量设置
* #set value
*/
utils.mixin(Velocity.prototype, {
/**
* 获取执行环境,对于macro中定义的变量,为局部变量,不贮存在全局中,执行后销毁
* get variable from context, if run in block, return local context, else return global context
*/
getContext: function() {
var condition = this.condition;
Expand Down
2 changes: 1 addition & 1 deletion src/helper/text.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = function(Helper, utils){
/**
* 获取引用文本,当引用自身不存在的情况下,需要返回原来的模板字符串
* get variable text
*/
function getRefText(ast){

Expand All @@ -20,7 +21,6 @@ module.exports = function(Helper, utils){
}

utils.forEach(ast.path, function(ref){
//不支持method并且传递参数
if (ref.type == 'method') {
ret += '.' + getMethodText(ref);
} else if (ref.type == 'index') {
Expand Down
4 changes: 3 additions & 1 deletion src/parse.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ function makeLevel(block, index) {

var isBlockType = blockTypes[type];

// 自定义类型支持
// support custom block , for example
// const vm = '#cms(1)<div class="abs-right"> #H(1,"第一个链接") </div> #end'
// parse(vm, { cms: true });
if (!isBlockType && ast.type === 'macro_call' && customBlocks[ast.id]) {
isBlockType = true;
ast.type = ast.id;
Expand Down

0 comments on commit 223ec38

Please sign in to comment.