Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion src/parse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ export function parse(this: Eta, str: string): Array<AstObject> {
);

const parseCloseReg = new RegExp(
"'|\"|`|\\/\\*|(\\s*(-|_)?" + escapeRegExp(config.tags[1]) + ")",
"'|\"|`|\\/\\*|\\/\\/|(\\s*(-|_)?" + escapeRegExp(config.tags[1]) + ")",
"g",
);

Expand Down Expand Up @@ -161,6 +161,17 @@ export function parse(this: Eta, str: string): Array<AstObject> {
ParseErr("unclosed comment", str, closeTag.index);
}
parseCloseReg.lastIndex = commentCloseInd;
} else if (char === "//") {
const lineTerminatorRegex = /[\n\r\u2028\u2029]/g;
Comment thread
rtritto marked this conversation as resolved.
Outdated
lineTerminatorRegex.lastIndex = parseCloseReg.lastIndex;
const match = lineTerminatorRegex.exec(str);
Comment thread
rtritto marked this conversation as resolved.
Outdated
if (match) {
parseCloseReg.lastIndex =
match.index +
(match[0] === "\r" && str[match.index + 1] === "\n" ? 2 : 1);
Comment thread
rtritto marked this conversation as resolved.
Outdated
} else {
parseCloseReg.lastIndex = str.length;
}
Comment thread
rtritto marked this conversation as resolved.
} else if (char === "'") {
singleQuoteReg.lastIndex = closeTag.index;

Expand Down