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.4.10 to 0.4.11

tests/script/syncRunner.js

4

History.md
## 0.4
### 0.4.11 / 2015-01-24
- feat: self define macro context keep to origin object
### 0.4.10 / 2015-01-08

@@ -4,0 +8,0 @@

25

index.js
'use strict';
var Parser = require('./src/parse/index');
var utils = require('./src/utils');
var Compile = require('./src/compile/index');
var Helper = {};
Parser._parse = Parser.parse;
Parser.parse = function (str) {
var asts = Parser._parse(str);
return utils.makeLevel(asts);
};
var Velocity = {
Parser : Parser,
Compile : Compile
};
Velocity.render = function (template, context, macros) {
var asts = Parser.parse(template);
var compile = new Compile(asts);
return compile.render(context, macros);
};
module.exports = Velocity;
module.exports = require('./src/velocity');
{
"name": "velocityjs",
"description": "Velocity Template Language(VTL) for JavaScript",
"version": "0.4.10",
"version": "0.4.11",
"keywords": [

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

@@ -82,4 +82,11 @@ module.exports = function(Velocity, utils){

var self = this;
if (!jsmacros.eval) {
jsmacros.eval = function() {
return self.eval.apply(self, arguments);
};
}
try {
ret = macro.apply(this, jsArgs);
ret = macro.apply(jsmacros, jsArgs);
} catch(e){

@@ -86,0 +93,0 @@ var pos = ast.pos;

@@ -89,2 +89,15 @@ var Velocity = require('../src/velocity')

it('this context should keep corrent in macro', function() {
var data = '#parse()'
var Macro = function(name) {
this.name = name;
};
Macro.prototype.parse = function() {
return this.name;
};
assert.equal('hanwen', render(data, {}, new Macro('hanwen')))
})
it('get variable form text', function(){

@@ -147,2 +160,6 @@ var vm = 'hello $user.getName().getFullName("hanwen")'

compile = new Compile(Parser.parse(vm), { unescape: { foo: true } })
ret = compile.render(context)
assert.equal(expected, ret)
compile = new Compile(Parser.parse(vm))

@@ -395,3 +412,3 @@ ret = compile.render(context)

assert.equal(ret, render(vm, data))
assert.equal(ret.trim(), render(vm, data).trim())

@@ -398,0 +415,0 @@ })

var Velocity = require('../src/velocity')
var assert = require("assert")
var getRefText = Velocity.Helper.getRefText;
var parse = Velocity.Parser.parse;
describe('Helper', function(){
var getRefText = Velocity.Helper.getRefText
var parse = Velocity.Parser.parse
describe('getRefText', function() {

@@ -8,0 +8,0 @@ it('simple reference', function() {

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc