Fix #23: tags containing "=" fail
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d02ca36..47c525c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -1,5 +1,9 @@
# CHANGELOG
+## 0.2.4
+
+* Fix #23 failure if tag or comment contains "="
+
## 0.2.3
* Change handling of lenient sections to match python mustache implementation.
diff --git a/lib/src/scanner.dart b/lib/src/scanner.dart
index ac900f3..b537b57 100644
--- a/lib/src/scanner.dart
+++ b/lib/src/scanner.dart
@@ -243,10 +243,10 @@
break;
default:
- // Indentifier can be any other character in lenient mode.
+ // Identifier can be any other character in lenient mode.
token = TokenType.identifier;
value = _readWhile((c) => !(const [ _HASH, _CARET, _FORWARD_SLASH,
- _GT, _AMP, _EXCLAIM, _EQUAL, _SPACE, _TAB, _NEWLINE, _RETURN,
+ _GT, _AMP, _EXCLAIM, _SPACE, _TAB, _NEWLINE, _RETURN,
_PERIOD].contains(c)) &&
c != _closeDelimiterInner &&
c != _closeDelimiter);
@@ -254,7 +254,7 @@
_append(token, value, start, _offset);
}
}
-
+
// Scan close delimiter token.
void _scanCloseDelimiter() {
diff --git a/pubspec.yaml b/pubspec.yaml
index 8d78998..61558d5 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -1,5 +1,5 @@
name: mustache
-version: 0.2.3
+version: 0.2.4
author: Greg Lowe <greg@vis.net.nz>
description: Mustache template library
homepage: https://github.com/xxgreg/mustache
diff --git a/test/parser_test.dart b/test/parser_test.dart
index 1de0027..8431946 100644
--- a/test/parser_test.dart
+++ b/test/parser_test.dart
@@ -107,6 +107,30 @@
new Token(TokenType.text, 'def', 14, 17)
]);
});
+
+ test('scan tag with equals', () {
+ var source = '{{foo=bar}}';
+ var scanner = new Scanner(source, 'foo', '{{ }}', lenient: true);
+ var tokens = scanner.scan();
+ expectTokens(tokens, [
+ new Token(TokenType.openDelimiter, '{{', 0, 2),
+ new Token(TokenType.identifier, 'foo=bar', 2, 9),
+ new Token(TokenType.closeDelimiter, '}}', 9, 11),
+ ]);
+ });
+
+ test('scan comment with equals', () {
+ var source = '{{!foo=bar}}';
+ var scanner = new Scanner(source, 'foo', '{{ }}', lenient: false);
+ var tokens = scanner.scan();
+ expectTokens(tokens, [
+ new Token(TokenType.openDelimiter, '{{', 0, 2),
+ new Token(TokenType.sigil, '!', 2, 3),
+ new Token(TokenType.identifier, 'foo=bar', 3, 10),
+ new Token(TokenType.closeDelimiter, '}}', 10, 12),
+ ]);
+ });
+
});
group('Parser', () {