Skip to content
This repository has been archived by the owner on Apr 11, 2018. It is now read-only.

Commit

Permalink
Merge pull request #455 from senorcris/bug/dotkey
Browse files Browse the repository at this point in the history
Allow variable tokens to start with `$`
  • Loading branch information
paularmstrong committed May 7, 2014
2 parents 3855260 + c0a2c2f commit 9b75436
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/lexer.js
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ var TYPES = {
{
type: TYPES.VAR,
regex: [
/^[a-zA-Z_$]\w*((\.\w*)+)?/,
/^[a-zA-Z_$]\w*((\.\$?\w*)+)?/,
/^[a-zA-Z_$]\w*/
]
},
Expand Down
5 changes: 3 additions & 2 deletions tests/variables.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ var cases = {
{ c: '{{ o.foo() }}', e: 'bar'},
{ c: '{{ o2.foo() }}', e: 'bar'},
{ c: '{{ o2.foo("foobar") }}', e: 'foobar'},
{ c: '{{ o2.bar }}', e: ''}
{ c: '{{ o2.bar }}', e: ''},
{ c: '{{ o2.$bar }}', e: 'bar'}
],
'can include arrays': [
{ c: '{{ [0, 1, 3] }}', e: '0,1,3' }
Expand Down Expand Up @@ -94,7 +95,7 @@ describe('Variables', function () {
i: 'foo',
n: null,
o: Object.create({ foo: function () { return 'bar'; } }),
o2: { a: 'bar', foo: function (b) { return b || this.a; } },
o2: { a: 'bar', foo: function (b) { return b || this.a; }, $bar: 'bar' },
o3: { n: null }
}};
_.each(cases, function (cases, description) {
Expand Down

0 comments on commit 9b75436

Please sign in to comment.