This commit is contained in:
Tobe O 2017-11-28 18:15:33 -05:00
parent 9a4cfc0563
commit 02bab763a3
5 changed files with 40 additions and 4 deletions

View file

@ -1,5 +1,5 @@
name: angel_jael name: angel_jael
version: 1.0.0-alpha+2 version: 1.0.0
description: Angel support for the Jael templating engine. description: Angel support for the Jael templating engine.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/jael/tree/master/jael homepage: https://github.com/angel-dart/jael/tree/master/jael

View file

@ -1,3 +1,4 @@
import 'package:charcode/ascii.dart';
import 'package:string_scanner/string_scanner.dart'; import 'package:string_scanner/string_scanner.dart';
import '../ast/ast.dart'; import '../ast/ast.dart';
@ -127,7 +128,27 @@ class _Scanner implements Scanner {
var lastToken = _scanFrom(_htmlPatterns, textStart); var lastToken = _scanFrom(_htmlPatterns, textStart);
if (lastToken?.type == TokenType.equals || if (lastToken?.type == TokenType.gt) {
if (!_scanner.isDone) {
var state = _scanner.state;
var ch = _scanner.peekChar();
if (ch != $space && ch != $cr && ch != $lf && ch != $tab) {
while (!_scanner.isDone) {
var ch = _scanner.peekChar();
if (ch == $lt || (ch == $open_brace && _scanner.peekChar() == $open_brace)) {
var span = _scanner.spanFrom(state);
tokens.add(new Token(TokenType.text, span));
break;
} else
_scanner.readChar();
}
}
}
}
else if (lastToken?.type == TokenType.equals ||
lastToken?.type == TokenType.nequ) { lastToken?.type == TokenType.nequ) {
textStart = null; textStart = null;
scanExpressionTokens(); scanExpressionTokens();

View file

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

View file

@ -18,6 +18,21 @@ main() {
expect(tokens[6], isToken(TokenType.gt)); expect(tokens[6], isToken(TokenType.gt));
}); });
test('single quotes', () {
var tokens = scan('<p>It\'s lit</p>', sourceUrl: 'test.jl').tokens;
tokens.forEach(print);
expect(tokens, hasLength(8));
expect(tokens[0], isToken(TokenType.lt));
expect(tokens[1], isToken(TokenType.id, 'p'));
expect(tokens[2], isToken(TokenType.gt));
expect(tokens[3], isToken(TokenType.text, 'It\'s lit'));
expect(tokens[4], isToken(TokenType.lt));
expect(tokens[5], isToken(TokenType.slash));
expect(tokens[6], isToken(TokenType.id, 'p'));
expect(tokens[7], isToken(TokenType.gt));
});
test('text node', () { test('text node', () {
var tokens = scan('<p>Hello\nworld</p>', sourceUrl: 'test.jl').tokens; var tokens = scan('<p>Hello\nworld</p>', sourceUrl: 'test.jl').tokens;
tokens.forEach(print); tokens.forEach(print);

View file

@ -1,5 +1,5 @@
name: jael_preprocessor name: jael_preprocessor
version: 1.0.0-alpha+2 version: 1.0.0
description: A pre-processor for resolving blocks and includes within Jael templates. description: A pre-processor for resolving blocks and includes within Jael templates.
author: Tobe O <thosakwe@gmail.com> author: Tobe O <thosakwe@gmail.com>
homepage: https://github.com/angel-dart/jael/tree/master/jael_processor homepage: https://github.com/angel-dart/jael/tree/master/jael_processor