Skip to content

Commit

Permalink
Merge pull request #26 from jwellner/fix-comments
Browse files Browse the repository at this point in the history
Fixes issue #25 where open/close comment tags where not matched correctly
  • Loading branch information
umakantp authored Jan 10, 2018
2 parents f22a859 + 53b2f36 commit 3a079ce
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/parser/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ define(['../util/objectmerge', '../util/trimallquotes', '../util/evalstring', '.
var rdelim = new RegExp('\\*' + this.rdelim)
var newTpl = ''

for (var openTag = tpl.match(ldelim); openTag; openTag = tpl.match(rdelim)) {
for (var openTag = tpl.match(ldelim); openTag; openTag = tpl.match(ldelim)) {
newTpl += tpl.slice(0, openTag.index)
tpl = tpl.slice(openTag.index + openTag[0].length)
var closeTag = tpl.match(rdelim)
Expand Down
5 changes: 5 additions & 0 deletions test/basic-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,11 @@ define(['jSmart', 'text!./templates/var.tpl', 'text!./output/var.tpl'], function
expect(t.fetch()).toBe('Testing , does it work?')
})

it('test comments', function () {
var t = new jSmart('Testing {* testing *}, does it {* multiple comments *}work?')
expect(t.fetch()).toBe('Testing , does it work?')
})

it('test assigning variable', function () {
var t = new jSmart("{$foo = 'bar'} print foo {$foo}")
expect(t.fetch()).toBe(' print foo bar')
Expand Down

0 comments on commit 3a079ce

Please sign in to comment.