Socket
Socket
Sign inDemoInstall

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 0.3.3 to 0.3.4

19

bin/velocity-cli.js

@@ -120,11 +120,24 @@ var path = require('path');

file = process.cwd() + '/' + file;
var pwd = process.cwd() + '/';
if (!fs.existsSync(file)) {
console.log('$ velocity --makeup xx.vm');
console.log('$ velocity --makeup xx.vm | xx.js');
return;
}
var extname = path.extname(file);
if (extname === '.vm') {
console.log(getVTL(file));
} else {
var compoment = require(file);
var files = compoment.files;
console.log(getVTL(files, compoment.context, compoment.macros));
}
}
function getVTL(file, context, macros){
var asts = Parser.parse(fs.readFileSync(file).toString());
var makeup = new Jsonify(asts);
console.log(makeup.toVTL());
var makeup = new Jsonify(asts, context, macros);
return makeup.toVTL();
}

@@ -131,0 +144,0 @@

2

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

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

@@ -215,4 +215,3 @@ ##Velocity - Template Engine [![Build Status](https://secure.travis-ci.org/shepherdwind/velocity.js.png)](https://travis-ci.org/shepherdwind/velocity.js)

Helper提供一些额外的功能,都在`src/helper/`目录下,使用方式参考`test/`下对应文件,
Helper功能还在开发中,可能不太完善。
Helper提供一些额外的功能,主要用于解决vm数据模拟问题。

@@ -223,2 +222,4 @@ - `structure` 获取vm中所有变量的结构: `$foo.bar` => `foo: {bar: 'string'}`

jsonify文档[issue #11](https://github.com/shepherdwind/velocity.js/issues/11)
```

@@ -225,0 +226,0 @@ hello world $foo.name.

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

return ret;
return ret || '';
},

@@ -54,0 +54,0 @@

@@ -60,4 +60,5 @@ module.exports = function(Velocity, utils){

hasSetMethod: function(ast, context){
var tools = { 'control': true };
var len = ast.path && ast.path.length;
if (!len) return false;
if (!len || tools[ast.id]) return false;

@@ -73,2 +74,4 @@ var lastId = '' + ast.path[len - 1].id;

if (ast.type === 'method' && ast.id.indexOf('set') === 0) {
if (context[ast.id]) {
}
context[ast.id.slice(3)] = this.getLiteral(ast.args[0]);

@@ -199,3 +202,3 @@ } else {

if (ret && ret.call) {
ret = ret.apply(baseRef, args);
ret = ret.apply(this, args);
} else {

@@ -202,0 +205,0 @@ ret = undefined;

@@ -105,18 +105,19 @@ module.exports = function(Velocity, utils){

isFn: function(ast){
var fn = this.fns.context;
var isNoPass = true;
fn = fn[ast.id];
var fns = this.fns.context;
fns = fns[ast.id];
var fn = null;
if (fn) {
var args = null;
isNoPass = utils.some(ast.path, function(a){
fn = fn[a.id];
args = a.args;
if (fns) {
utils.each(ast.path, function(a){
if (typeof fns[a.id] === 'function') {
fn = fns[a.id];
}
fn = fns[a.id];
var _arg = [];
utils.forEach(args, function(arg){
_arg.push(arg.value);
});
return !fn;
});
}, this);
var _arg = [];
utils.forEach(args, function(arg){
_arg.push(arg.value);
});

@@ -123,0 +124,0 @@ fn.apply(this, _arg);

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