Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

velocityjs

Package Overview
Dependencies
Maintainers
1
Versions
78
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

velocityjs - npm Package Compare versions

Comparing version 1.1.3 to 1.1.4

5

History.md

@@ -0,1 +1,6 @@

## 1.1.4 2019-08-27
- Added support for remove in ArrayList and Map @mdrewt [#124](https://github.com/shepherdwind/velocity.js/pull/124)
- Support format quiet syntax ${ ref }, fix [#120](https://github.com/shepherdwind/velocity.js/pull/120)
## 1.1.3 2018-09-18

@@ -2,0 +7,0 @@

2

package.json
{
"name": "velocityjs",
"description": "Velocity Template Language(VTL) for JavaScript",
"version": "1.1.3",
"version": "1.1.4",
"license": "MIT",

@@ -6,0 +6,0 @@ "keywords": [

@@ -10,3 +10,3 @@ Velocity - Template Engine

##Features
## Features

@@ -18,3 +18,3 @@ - 支持客户端和服务器端使用

##Install
## Install

@@ -27,3 +27,3 @@ via npm:

##Broswer
## Broswer

@@ -38,3 +38,3 @@ 兼容支持es5的浏览器,可以通过测试来验证[test case](http://git.shepherdwind.com/velocity.js/runner/tests.html)。

##Examples
## Examples

@@ -44,3 +44,3 @@ 在tests目录下有大量的例子,node和浏览器下使用是一致的,另外,examples目录下有一个

##Public API
## Public API

@@ -62,3 +62,3 @@ 文件组织通过CommonJS方式,对于浏览器,通过spm可以打包为cmd模块。

####context
#### context

@@ -71,7 +71,7 @@ `context`是一个对象,可以为空,执行中`$foo.bar`,访问路径是`context.foo.bar`,

##Syntax
## Syntax
具体语法请访问官网文档:[velocity user guide](http://velocity.apache.org/engine/devel/user-guide.html)。
###Directives
### Directives

@@ -82,3 +82,3 @@ Directives支持`set`, `foreach`, `if|else|elseif`, `macro`, `break`。不

###macro与parse
### macro与parse

@@ -89,3 +89,3 @@ 宏分为系统的宏,比如`parse, include`,和用户自定义宏,通过`#macro`在vm中定义,此

##Questions
## Questions

@@ -102,4 +102,4 @@ 提问有几种方式

##License
## License
(The MIT License)

@@ -5,8 +5,6 @@ 'use strict';

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

@@ -97,2 +95,3 @@

// bug修复:此处由于闭包特性,导致eval函数执行时的this对象是上一次函数执行时的this对象,渲染时上下文发生错误。
// js macros export evel function
jsmacros.eval = function() {

@@ -141,5 +140,5 @@ return self.eval.apply(self, arguments);

* 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}

@@ -217,3 +216,3 @@ */

}
// 构造临时变量
// for each local variable
local[_to] = val;

@@ -220,0 +219,0 @@ local.foreach = {

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

/**
* @param context {object} 上下文环境,数据对象
* @param context {object} context object
* @param macro {object} self defined #macro

@@ -29,0 +29,0 @@ * @param silent {bool} 如果是true,$foo变量将原样输出

module.exports = function(Velocity, utils){
/**
* expression运算
* expression support, include math, logic, compare expression
*/

@@ -5,0 +5,0 @@ utils.mixin(Velocity.prototype, {

@@ -7,3 +7,3 @@ var utils = require('../utils');

{
// 自动输出为经过html encode输出
// 自动输出为经过html e输出
escape: true,

@@ -10,0 +10,0 @@ // 不需要转义的白名单

'use strict';
module.exports = function(Velocity, utils) {
/**
* literal解释模块
* literal parse, include string, integer, array, map, bool data structure
* @require {method} getReferences

@@ -12,3 +12,3 @@ */

* 是literal值描述
* @return {object|string|number|array}返回对应的js变量
* @return {object|string|number|array} js variable
*/

@@ -15,0 +15,0 @@ getLiteral: function(literal) {

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

/**
* unicode转码
* unicode encode
*/

@@ -273,2 +273,28 @@ function convert(str) {

return baseRef.push(this.getLiteral(property.args[0]));
} else if (id === 'remove') {
if (utils.isArray(baseRef)) {
if (typeof index === 'number') {
var index = this.getLiteral(property.args[0]);
} else {
var index = baseRef.indexOf(this.getLiteral(property.args[0]));
}
ret = baseRef[index];
baseRef.splice(index, 1);
return ret;
} else if (utils.isObject(baseRef)) {
ret = baseRef[this.getLiteral(property.args[0])];
delete baseRef[this.getLiteral(property.args[0])];
return ret;
}
return undefined;
} else if (id === 'subList' && !baseRef[id]) {
return baseRef.slice(this.getLiteral(property.args[0]), this.getLiteral(property.args[1]));
} else {

@@ -275,0 +301,0 @@

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
*/

@@ -9,0 +9,0 @@ getContext: function() {

module.exports = function(Helper, utils){
/**
* 获取引用文本,当引用自身不存在的情况下,需要返回原来的模板字符串
* get variable text
*/

@@ -23,3 +24,2 @@ function getRefText(ast){

utils.forEach(ast.path, function(ref){
//不支持method并且传递参数
if (ref.type == 'method') {

@@ -26,0 +26,0 @@ ret += '.' + getMethodText(ref);

@@ -62,3 +62,5 @@ 'use strict';

// 自定义类型支持
// 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]) {

@@ -65,0 +67,0 @@ isBlockType = true;

@@ -76,3 +76,3 @@ /* parser generated by jison 0.4.18 */

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,9],$V2=[1,19],$V3=[1,10],$V4=[1,24],$V5=[1,25],$V6=[1,23],$V7=[4,10,11,20,35,36,46,82],$V8=[1,29],$V9=[1,33],$Va=[1,32],$Vb=[4,10,11,20,23,35,36,39,46,49,50,51,54,55,56,57,58,59,60,61,62,63,64,65,66,82,84,94],$Vc=[1,50],$Vd=[1,55],$Ve=[1,56],$Vf=[1,72],$Vg=[1,71],$Vh=[1,84],$Vi=[1,79],$Vj=[1,87],$Vk=[1,95],$Vl=[1,85],$Vm=[1,90],$Vn=[1,94],$Vo=[1,91],$Vp=[1,92],$Vq=[4,10,11,20,23,35,36,39,46,49,50,51,54,55,56,57,58,59,60,61,62,63,64,65,66,75,80,82,83,84,94],$Vr=[1,107],$Vs=[1,121],$Vt=[1,117],$Vu=[1,118],$Vv=[1,131],$Vw=[23,50,84],$Vx=[2,96],$Vy=[23,39,49,50,84],$Vz=[23,39,49,50,54,55,56,57,58,59,60,61,62,63,64,65,66,82,84],$VA=[23,39,49,50,54,55,56,57,58,59,60,61,62,63,64,65,66,82,84,96],$VB=[2,109],$VC=[23,39,49,50,54,55,56,57,58,59,60,61,62,63,64,65,66,82,84,94],$VD=[2,112],$VE=[1,140],$VF=[1,146],$VG=[23,49,50],$VH=[1,151],$VI=[1,152],$VJ=[1,153],$VK=[1,154],$VL=[1,155],$VM=[1,156],$VN=[1,157],$VO=[1,158],$VP=[1,159],$VQ=[1,160],$VR=[1,161],$VS=[1,162],$VT=[1,163],$VU=[23,54,55,56,57,58,59,60,61,62,63,64,65,66],$VV=[50,84],$VW=[2,113],$VX=[23,35],$VY=[1,213],$VZ=[1,212],$V_=[39,50],$V$=[23,54,55],$V01=[23,54,55,56,57,61,62,63,64,65,66],$V11=[23,54,55,61,62,63,64,65,66];
var parser = {trace: function trace() { },
var parser = {trace: function trace () { },
yy: {},

@@ -319,3 +319,3 @@ symbols_: {"error":2,"root":3,"EOF":4,"statements":5,"statement":6,"references":7,"directives":8,"content":9,"RAW":10,"COMMENT":11,"set":12,"if":13,"elseif":14,"else":15,"end":16,"foreach":17,"break":18,"define":19,"HASH":20,"NOESCAPE":21,"PARENTHESIS":22,"CLOSE_PARENTHESIS":23,"macro":24,"macro_call":25,"macro_body":26,"SET":27,"equal":28,"IF":29,"expression":30,"ELSEIF":31,"ELSE":32,"END":33,"FOREACH":34,"DOLLAR":35,"ID":36,"IN":37,"MAP_BEGIN":38,"MAP_END":39,"array":40,"BREAK":41,"DEFINE":42,"MACRO":43,"macro_args":44,"macro_call_args_all":45,"MACRO_BODY":46,"macro_call_args":47,"literals":48,"SPACE":49,"COMMA":50,"EQUAL":51,"map":52,"math":53,"||":54,"&&":55,"+":56,"-":57,"*":58,"/":59,"%":60,">":61,"<":62,"==":63,">=":64,"<=":65,"!=":66,"parenthesis":67,"!":68,"literal":69,"brace_begin":70,"attributes":71,"brace_end":72,"methodbd":73,"VAR_BEGIN":74,"VAR_END":75,"attribute":76,"method":77,"index":78,"property":79,"DOT":80,"params":81,"CONTENT":82,"BRACKET":83,"CLOSE_BRACKET":84,"string":85,"number":86,"BOOL":87,"integer":88,"INTEGER":89,"DECIMAL_POINT":90,"STRING":91,"EVAL_STRING":92,"range":93,"RANGE":94,"map_item":95,"MAP_SPLIT":96,"$accept":0,"$end":1},

defaultActions: {2:[2,1],26:[2,2],32:[2,82],33:[2,83],113:[2,52],114:[2,53],190:[2,51],212:[2,112],225:[2,113]},
parseError: function parseError(str, hash) {
parseError: function parseError (str, hash) {
if (hash.recoverable) {

@@ -608,3 +608,3 @@ this.trace(str);

// test the lexed token: return FALSE when not a match, otherwise return token
test_match:function (match, indexed_rule) {
test_match:function(match, indexed_rule) {
var token,

@@ -739,3 +739,3 @@ lines,

// return next match that has a token
lex:function lex() {
lex:function lex () {
var r = this.next();

@@ -750,3 +750,3 @@ if (r) {

// activates a new lexer condition state (pushes the new lexer condition state onto the condition stack)
begin:function begin(condition) {
begin:function begin (condition) {
this.conditionStack.push(condition);

@@ -756,3 +756,3 @@ },

// pop the previously active lexer condition state off the condition stack
popState:function popState() {
popState:function popState () {
var n = this.conditionStack.length - 1;

@@ -767,3 +767,3 @@ if (n > 0) {

// produce the lexer rule set which is active for the currently active lexer condition state
_currentRules:function _currentRules() {
_currentRules:function _currentRules () {
if (this.conditionStack.length && this.conditionStack[this.conditionStack.length - 1]) {

@@ -777,3 +777,3 @@ return this.conditions[this.conditionStack[this.conditionStack.length - 1]].rules;

// return the currently active lexer condition state; when an index argument is provided it produces the N-th previous condition state, if available
topState:function topState(n) {
topState:function topState (n) {
n = this.conditionStack.length - 1 - Math.abs(n || 0);

@@ -788,3 +788,3 @@ if (n >= 0) {

// alias for begin(condition)
pushState:function pushState(condition) {
pushState:function pushState (condition) {
this.begin(condition);

@@ -1004,3 +1004,3 @@ },

},
rules: [/^(?:[^#]*?(?=\$))/,/^(?:[^\$]*?(?=#))/,/^(?:[^\x00]+)/,/^(?:#\*[\s\S]+?\*#)/,/^(?:#\[\[[\s\S]+?\]\]#)/,/^(?:##[^\n]*)/,/^(?:#@)/,/^(?:#(?=[a-zA-Z{]))/,/^(?:set[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:if[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:elseif[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:else\b)/,/^(?:\{else\})/,/^(?:end\b)/,/^(?:\{end\})/,/^(?:break\b)/,/^(?:foreach[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:noescape(?=[^a-zA-Z0-9_]+))/,/^(?:define[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:macro[ ]*(?=[^a-zA-Z0-9_]+))/,/^(?:in\b)/,/^(?:[%\+\-\*\/])/,/^(?:<=)/,/^(?:le\b)/,/^(?:>=)/,/^(?:ge\b)/,/^(?:[><])/,/^(?:gt\b)/,/^(?:lt\b)/,/^(?:==)/,/^(?:eq\b)/,/^(?:\|\|)/,/^(?:or\b)/,/^(?:&&)/,/^(?:and\b)/,/^(?:!=)/,/^(?:ne\b)/,/^(?:not\b)/,/^(?:\$!(?=[{a-zA-Z_]))/,/^(?:\$(?=[{a-zA-Z_]))/,/^(?:!)/,/^(?:=)/,/^(?:[ ]+(?=[^,]))/,/^(?:\s+)/,/^(?:\{)/,/^(?:\})/,/^(?::[\s]*)/,/^(?:\{)/,/^(?:\})/,/^(?:\([\s]*(?=[$'"\[\{\-0-9\w()!]))/,/^(?:\))/,/^(?:\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(?:=)/,/^(?:[ ]+(?=[^,]))/,/^(?:\s+)/,/^(?:\{)/,/^(?:\})/,/^(?::[\s]*)/,/^(?:\{[\s]*)/,/^(?:[\s]*\})/,/^(?:\([\s]*(?=[$'"\[\{\-0-9\w()!]))/,/^(?:\))/,/^(?:\[[\s]*(?=[\-$"'0-9{\[\]]+))/,/^(?:\])/,/^(?:\.\.)/,/^(?:\.(?=[a-zA-Z_]))/,/^(?:\.(?=[\d]))/,/^(?:,[ ]*)/,/^(?:"(\\"|[^\"])*")/,/^(?:'(\\'|[^\'])*')/,/^(?:null\b)/,/^(?:false\b)/,/^(?:true\b)/,/^(?:[0-9]+)/,/^(?:[_a-zA-Z][a-zA-Z0-9_\-]*)/,/^(?:[_a-zA-Z][a-zA-Z0-9_\-]*[ ]*(?=\())/,/^(?:#)/,/^(?:.)/,/^(?:\s+)/,/^(?:[\$#])/,/^(?:$)/,/^(?:$)/],
conditions: {"mu":{"rules":[5,38,39,47,48,49,50,51,52,54,63,65,66,67,69],"inclusive":false},"c":{"rules":[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,49,50,51,52,54,55,56,57,58,59,60,61,62,63],"inclusive":false},"i":{"rules":[20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,43,44,44,45,45,46,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63],"inclusive":false},"h":{"rules":[3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,38,39,40,41,46,49,50,51,52,54,62,64,66,67,69],"inclusive":false},"esc":{"rules":[68],"inclusive":false},"run":{"rules":[38,39,40,42,43,44,45,46,49,50,51,52,54,55,56,57,58,59,60,61,62,63,66,67,69],"inclusive":false},"INITIAL":{"rules":[0,1,2,70],"inclusive":true}}

@@ -1023,3 +1023,3 @@ });

exports.parse = function () { return velocity.parse.apply(velocity, arguments); };
exports.main = function commonjsMain(args) {
exports.main = function commonjsMain (args) {
if (!args[1]) {

@@ -1026,0 +1026,0 @@ console.log('Usage: '+args[0]+' FILE');

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc