velocityjs
Advanced tools
Comparing version 0.4.1 to 0.4.2
@@ -94,3 +94,5 @@ var path = require('path'); | ||
var ext = path.extname(dataFile); | ||
dataFile = path.resolve(process.cwd(), dataFile); | ||
if (dataFile) { | ||
dataFile = path.resolve(process.cwd(), dataFile); | ||
} | ||
@@ -97,0 +99,0 @@ if (ext === '.json') { |
{ | ||
"name": "velocityjs", | ||
"description": "Velocity Template Language(VTL) for JavaScript", | ||
"version": "0.4.1", | ||
"version": "0.4.2", | ||
"keywords": [ | ||
@@ -6,0 +6,0 @@ "velocity template" |
@@ -74,3 +74,3 @@ module.exports = function(Velocity, utils){ | ||
var guid = utils.guid(); | ||
var contextId = ast.id + ':' + guid; | ||
var contextId = 'macro:' + ast.id + ':' + guid; | ||
@@ -77,0 +77,0 @@ utils.forEach(args, function(ref, i){ |
module.exports = function(Velocity, utils){ | ||
'use strict' | ||
@@ -23,2 +24,3 @@ function getSize(obj){ | ||
var escape = false | ||
var i, c, cstr; | ||
@@ -25,0 +27,0 @@ for(i = 0 ; i < str.length ; i++) { |
@@ -24,2 +24,8 @@ module.exports = function(Velocity, utils){ | ||
var context = this.getContext(); | ||
//see https://github.com/shepherdwind/velocity.js/issues/25 | ||
if (this.condition && this.condition.indexOf('macro:') === 0) { | ||
context = this.context; | ||
} | ||
var valAst = ast.equal[1]; | ||
@@ -26,0 +32,0 @@ var val; |
@@ -188,2 +188,7 @@ var Velocity = require('../src/velocity') | ||
it('#set context should be global, #25', function(){ | ||
var vm = '#macro(local) #set($val =1) $val #end #local() $val' | ||
var ret = render(vm).replace(/\s+/g, '') | ||
assert.equal('11', ret) | ||
}) | ||
}) | ||
@@ -326,2 +331,8 @@ | ||
it('#foreach with #macro, $velocityCount should work find, #25', function(){ | ||
var vm = '#macro(local) #end #foreach ($one in [1,2,4]) #local() $velocityCount #end' | ||
var ret = render(vm).replace(/\s+/g, '') | ||
assert.equal('123', ret) | ||
}) | ||
it('#break', function(){ | ||
@@ -328,0 +339,0 @@ var vm = '#foreach($num in [1..6]) #if($foreach.count > 3) #break #end $num #end' |
424306
3887