Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add support for alternate attribute syntax.

  • Loading branch information...
commit 8c5efc1e3c96636f4fc37b494f5b36bb35c356f5 1 parent ff2bfa9
@creationix authored
Showing with 13 additions and 6 deletions.
  1. +11 −6 lib/haml.js
  2. +1 −0  test/alt_attribs.haml
  3. +1 −0  test/alt_attribs.html
View
17 lib/haml.js
@@ -54,17 +54,22 @@ if (exports) {
count = 1,
quote = false,
skip = false,
+ open, close, joiner, seperator,
pair = {
start: 1,
middle: null,
end: null
};
- if (!(l > 0 && line.charAt(0) === '{')) {
+ if (!(l > 0 && (line.charAt(0) === '{' || line.charAt(0) === '('))) {
return {
content: line[0] === ' ' ? line.substr(1, l) : line
};
}
+ open = line.charAt(0);
+ close = (open === '{') ? '}' : ')';
+ joiner = (open === '{') ? ':' : '=';
+ seperator = (open === '{') ? ',' : ' ';
function process_pair() {
var key = line.substr(pair.start, pair.middle - pair.start).trim(),
@@ -101,22 +106,22 @@ if (exports) {
}
if (count === 1) {
- if (c === ':') {
+ if (c === joiner) {
pair.middle = i;
}
- if (c === ',' || c === '}') {
+ if (c === seperator || c === close) {
pair.end = i;
process_pair();
- if (c === ',') {
+ if (c === seperator) {
pair.start = i + 1;
}
}
}
- if (c === '{') {
+ if (c === open) {
count += 1;
}
- if (c === '}') {
+ if (c === close) {
count -= 1;
}
}
View
1  test/alt_attribs.haml
@@ -0,0 +1 @@
+%tag(name="value" name2=true, ns:tag=100)
View
1  test/alt_attribs.html
@@ -0,0 +1 @@
+<tag name="value" name2="name2" ns:tag="100"></tag>
Please sign in to comment.
Something went wrong with that request. Please try again.