skip comments in free text

This commit is contained in:
Tobe O 2018-04-03 14:21:50 -04:00
parent 1cc960044e
commit 314c972cb0
3 changed files with 10 additions and 2 deletions

View file

@ -1,3 +1,6 @@
# 1.0.4
* Skip HTML comments in free text.
# 1.0.3
* Fix a scanner bug that prevented proper parsing of HTML nodes
followed by free text.

View file

@ -20,13 +20,15 @@ abstract class Scanner {
List<Token> get tokens;
}
final RegExp _htmlComment = new RegExp(r'<!--[^$]*-->');
final Map<Pattern, TokenType> _expressionPatterns = {
//final Map<Pattern, TokenType> _htmlPatterns = {
'{{': TokenType.doubleCurlyL,
'{{-': TokenType.doubleCurlyL,
//
new RegExp(r'<!--[^$]*-->'): TokenType.htmlComment,
_htmlComment: TokenType.htmlComment,
'!DOCTYPE': TokenType.doctype,
'!doctype': TokenType.doctype,
'<': TokenType.lt,
@ -99,6 +101,9 @@ class _Scanner implements Scanner {
var start = _scanner.state, end = start;
while (!_scanner.isDone) {
// Skip through comments
if (_scanner.scan(_htmlComment)) continue;
// Break on {{
if (_scanner.matches('{{')) {
state = _ScannerState.html;

View file

@ -1,5 +1,5 @@
name: jael
version: 1.0.3
version: 1.0.4
description: A simple server-side HTML templating engine for Dart.
author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/jael/tree/master/jael