Permalink
Browse files

Fixed support for quoted attribute keys ex `rss("xmlns:atom"="atom")`

  • Loading branch information...
1 parent 37cd0d8 commit 8162161e04ef9d569f6a13d9b9df19e8c556efb5 @tj tj committed Mar 30, 2011
Showing with 28 additions and 9 deletions.
  1. +25 −9 lib/lexer.js
  2. +3 −0 test/jade.test.js
View
@@ -325,6 +325,9 @@ Lexer.prototype = {
case ':':
case '=':
switch (state()) {
+ case 'key char':
+ key += c;
+ break;
case 'val':
case 'expr':
case 'array':
@@ -362,19 +365,32 @@ Lexer.prototype = {
break;
case '"':
case "'":
- if ('key' == state()) break;
- 'string' == state()
- ? states.pop()
- : states.push('string');
- val += c;
+ switch (state()) {
+ case 'key':
+ states.push('key char');
+ break;
+ case 'key char':
+ states.pop();
+ break;
+ case 'string':
+ states.pop();
+ val += c;
+ break;
+ default:
+ states.push('string');
+ val += c;
+ }
break;
case '':
break;
default:
- if ('key' == state()) {
- key += c;
- } else {
- val += c;
+ switch (state()) {
+ case 'key':
+ case 'key char':
+ key += c;
+ break;
+ default:
+ val += c;
}
}
}
View
@@ -509,6 +509,9 @@ module.exports = {
assert.equal('<a href="def">Foo</a>', render("a(href={test: 'abcdefg'}.test.substr(3,3)) Foo"));
assert.equal('<a href="def">Foo</a>', render("a(href={test: 'abcdefg'}.test.substr(3,[0,3][1])) Foo"));
+ assert.equal('<rss xmlns:atom="atom"></rss>', render("rss('xmlns:atom'=\"atom\")"));
+ assert.equal('<rss xmlns:atom="atom"></rss>', render("rss(\"xmlns:atom\"='atom')"));
+ assert.equal('<rss xmlns:atom="atom" foo="bar"></rss>', render("rss('xmlns:atom'=\"atom\", 'foo': 'bar')"));
assert.equal('<a data-obj="{ foo: \'bar\' }"></a>', render("a(data-obj: \"{ foo: 'bar' }\")"));
},

0 comments on commit 8162161

Please sign in to comment.