Skip to content

Commit

Permalink
Merge pull request #52 from briantani/master
Browse files Browse the repository at this point in the history
error rendering values as a result of a string function.
  • Loading branch information
shepherdwind committed Oct 28, 2015
2 parents 1598942 + f2a2d76 commit 319c464
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/compile/references.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,9 +270,11 @@ module.exports = function(Velocity, utils) {

var that = this;

baseRef.eval = function() {
return that.eval.apply(that, arguments);
};
if(typeof baseRef === 'object'){
baseRef.eval = function() {
return that.eval.apply(that, arguments);
};
}

try {
ret = ret.apply(baseRef, args);
Expand Down
14 changes: 14 additions & 0 deletions tests/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,20 @@ describe('Compile', function() {
assert.equal("monica", getContext(vm).monkey.Friend)
assert.equal("123", getContext(vm).monkey.Number)
})

it('set equal to result of method ', function () {
var vm = "#set( $monkey = 'monica' ) ## string literal\n" +
'#set( $result = $monkey.substring(1) ) ##calling method'
assert.equal("monica", getContext(vm).monkey)
assert.equal("onica", getContext(vm).result)
})

it('set equal to result of method ', function () {
var vm = "#set( $monkey = 1234 ) ## number literal\n" +
'#set( $result = $monkey.toString() ) ##calling method'
assert.equal("1234", getContext(vm).monkey)
assert.equal("1234", getContext(vm).result)
})

it('equal to method/property reference', function() {
var vm = "#set($monkey.Blame = $spindoctor.Leak) ## property \n" +
Expand Down

0 comments on commit 319c464

Please sign in to comment.