Skip to content

Commit

Permalink
Allow optional space after : in map passed as parameter to macro
Browse files Browse the repository at this point in the history
  • Loading branch information
jamescookie committed Jan 7, 2015
1 parent 6b8e9a9 commit 8dd19a2
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/parse/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/parse/velocity.l
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
<c,run,i>\s+ { /*ignore whitespace*/ }
<i,run,c,i>"{" { return 'MAP_BEGIN'; }
<i,run,c,i>"}" { return 'MAP_END'; }
<h,run,c,i>":" { return 'MAP_SPLIT'; }
<h,run,c,i>":"[\s]* { return 'MAP_SPLIT'; }
<mu>"{" { yy.begin = true; return 'VAR_BEGIN'; }
<mu>"}" { this.popState(); if (yy.begin === true) { yy.begin = false; return 'VAR_END';} else { return 'CONTENT'; } }
<mu,h,run,c,i>"("[\s]*/[$'"\[\{\-0-9\w()!] { this.begin("c"); return 'PARENTHESIS'; }
Expand Down
5 changes: 5 additions & 0 deletions tests/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,11 @@ describe('Compile', function(){
assert.equal(' abd', render(vm, {foo: 'a', bar: 'b', dd: 'd'}))
})

it('#macro map argument', function(){
var vm = '#macro( d $a)#foreach($_item in $a.entrySet())$_item.key = $_item.value #end#end #d ( {"foo": $foo,"bar":$bar} )'
assert.equal(' foo = a bar = b ', render(vm, {foo: 'a', bar: 'b'}))
})

it('#noescape', function(){
var vm = '#noescape()$hello#end'
assert.equal('hello world', render(vm, {hello: 'hello world'}))
Expand Down
5 changes: 5 additions & 0 deletions tests/runner/spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,11 @@ describe('Compile', function(){
assert.equal(' abd', render(vm, {foo: 'a', bar: 'b', dd: 'd'}))
})

it('#macro map argument', function(){
var vm = '#macro( d $a)#foreach($_item in $a.entrySet())$_item.key = $_item.value #end#end #d ( {"foo": $foo,"bar":$bar} )'
assert.equal(' foo = a bar = b ', render(vm, {foo: 'a', bar: 'b'}))
})

it('#noescape', function(){
var vm = '#noescape()$hello#end'
assert.equal('hello world', render(vm, {hello: 'hello world'}))
Expand Down

0 comments on commit 8dd19a2

Please sign in to comment.