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.9.4 to 0.9.5

4

History.md

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

## 0.9.5 2017-04-07
- fix: support foreach.hasnext when iterating objects [!81](https://github.com/shepherdwind/velocity.js/pull/81)
## 0.9.4 2017-01-16

@@ -2,0 +6,0 @@

2

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

@@ -6,0 +6,0 @@ "velocity template"

@@ -198,26 +198,39 @@ 'use strict';

var len = utils.isArray(_from) ? _from.length : utils.keys(_from).length;
if (utils.isArray(_from)) {
var len = _from.length;
utils.forEach(_from, function(val, i) {
if (this._state.break) {
return;
}
// 构造临时变量
local[_to] = val;
local.foreach = {
count: i + 1,
index: i,
hasNext: i + 1 < len
};
local.velocityCount = i + 1;
utils.forEach(_from, function(val, i) {
this.local[contextId] = local;
ret += this._render(_block, contextId);
if (this._state.break) {
return;
}
// 构造临时变量
local[_to] = val;
// TODO: here, the foreach variable give to local, when _from is not an
// array, count and hasNext would be undefined, also i is not the
// index.
local.foreach = {
count: i + 1,
index: i,
hasNext: i + 1 < len
};
local.velocityCount = i + 1;
}, this);
} else {
var len = utils.keys(_from).length;
utils.forEach(utils.keys(_from), function(key, i) {
if (this._state.break) {
return;
}
local[_to] = _from[key];
local.foreach = {
count: i + 1,
index: i,
hasNext: i + 1 < len
};
local.velocityCount = i + 1;
this.local[contextId] = local;
ret += this._render(_block, contextId);
}, this);
}
this.local[contextId] = local;
ret += this._render(_block, contextId);
}, this);
// if foreach items be an empty array, then this code will shift current

@@ -224,0 +237,0 @@ // conditions, but not this._render call, so this will shift parent context

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc