Skip to content

Commit

Permalink
Merge pull request #356 from guille/trailing-semicolon
Browse files Browse the repository at this point in the history
Trailing semicolon
  • Loading branch information
tj committed Oct 3, 2011
2 parents 296be5d + 245301c commit c43e0a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/lexer.js
Expand Up @@ -270,7 +270,7 @@ Lexer.prototype = {

assignment: function() {
var captures;
if (captures = /^(\w+) += *([^\n]+)/.exec(this.input)) {
if (captures = /^(\w+) += *([^ ;\n]+)( *;? *\n?)/.exec(this.input)) {
this.consume(captures[0].length);
var name = captures[1]
, val = captures[2];
Expand Down
11 changes: 11 additions & 0 deletions test/jade.test.js
Expand Up @@ -964,5 +964,16 @@ module.exports = {
assert.equal(tag.getAttribute(name), val)
tag.removeAttribute(name)
assert.isUndefined(tag.getAttribute(name))
},

'test assignment': function(assert){
assert.equal('<div>5</div>', render('a = 5;\ndiv= a'));
assert.equal('<div>5</div>', render('a = 5\ndiv= a'));
assert.equal('<div>5</div>', render('a = 5 \ndiv= a'));
assert.equal('<div>5</div>', render('a = 5 ; \ndiv= a'));

var fn = jade.compile('test = local\np=test');
assert.equal('<p>bar</p>', fn({ local: 'bar' }));
}

};

0 comments on commit c43e0a2

Please sign in to comment.