Skip to content

Commit

Permalink
fix: Support format quiet syntax $!{ reference }
Browse files Browse the repository at this point in the history
close #120
  • Loading branch information
shepherdwind committed Aug 27, 2019
1 parent 223ec38 commit 47d5a98
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
1 change: 1 addition & 0 deletions History.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 1.1.4 2019-08-27

- Added support for remove in ArrayList and Map @mdrewt [#124](https://github.com/shepherdwind/velocity.js/pull/124)
- Support format quiet syntax ${ ref }, fix [#120](https://github.com/shepherdwind/velocity.js/pull/120)

## 1.1.3 2018-09-18

Expand Down
22 changes: 11 additions & 11 deletions src/parse/index.js

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

4 changes: 2 additions & 2 deletions src/parse/velocity.l
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@
<i,run,c,i>"{" { return 'MAP_BEGIN'; }
<i,run,c,i>"}" { return 'MAP_END'; }
<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>"{"[\s]* { yy.begin = true; return 'VAR_BEGIN'; }
<mu>[\s]*"}" { 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'; }
<mu,h,run,c,i>")" {
if (this.popState() === "c") {
Expand Down
8 changes: 8 additions & 0 deletions tests/compile.js
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,14 @@ describe('Compile', function() {
var expected = 'bar';
assert.equal(render(vm).trim(), expected)
});
it('fix issue #120, push only', function() {
var vm = `
#set($foo = {})
$!{ foo.put("a", 1) }
`;
var expected = '1';
assert.equal(render(vm).trim(), expected)
});
it('should set a key to an object', function() {
var vm = `
$foo.put()
Expand Down

0 comments on commit 47d5a98

Please sign in to comment.