Allow empty comments
This commit is contained in:
parent
cd1d14ee8b
commit
d9749da99f
@ -2,6 +2,7 @@ import { CharacterStream } from './character_stream.mjs';
|
||||
import { TemplateSyntaxError } from './errors/template_syntax_error.mjs';
|
||||
|
||||
export class TokenStream {
|
||||
static ESCAPE = '\\';
|
||||
static OPEN_INLINE = '<%';
|
||||
static CLOSE_INLINE = '%>';
|
||||
static OPEN_INLINE_UNESCAPED = '<!%';
|
||||
@ -62,6 +63,11 @@ export class TokenStream {
|
||||
// Skip shebang (can be used to execute templates directly with an
|
||||
// interpreter that first builds the template and then executes)
|
||||
this._skipShebang();
|
||||
} else if (this._cs.isNext(TokenStream.ESCAPE)) {
|
||||
// Skip space
|
||||
this._cs.next();
|
||||
// Treat everything as raw until next space
|
||||
raw += this._cs.nextWhile((c) => /\S/.test(c));
|
||||
} else if (this._cs.isNext(TokenStream.OPEN_INLINE)) {
|
||||
return flushRaw() || this._readInline();
|
||||
} else if (this._cs.isNext(TokenStream.OPEN_INLINE_UNESCAPED)) {
|
||||
@ -174,13 +180,13 @@ export class TokenStream {
|
||||
// Skip tag
|
||||
this._cs.next(tag.length);
|
||||
|
||||
// Check for mandatory space
|
||||
if (this._cs.peek() !== ' ') {
|
||||
// Check for mandatory space/tab/new line
|
||||
if (this._isSpace(this._cs.peek())) {
|
||||
// Consume space
|
||||
this._cs.next();
|
||||
} else if (/[^\r\n]/.test(this._cs.peek())) {
|
||||
this._missingFullLineSpaceError(tag);
|
||||
}
|
||||
|
||||
// Consume space
|
||||
this._cs.next();
|
||||
|
||||
// Remainder of line is value
|
||||
const value = this._cs.nextWhile((c) => c !== '\n');
|
||||
|
Loading…
Reference in New Issue
Block a user