Skip to content

Commit

Permalink
Revert "#308 fix for backtick in comment within content block"
Browse files Browse the repository at this point in the history
This reverts commit 0c83398.
  • Loading branch information
casid committed Jan 27, 2024
1 parent 6500412 commit 818beb7
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 24 deletions.
5 changes: 0 additions & 5 deletions jte/src/main/java/gg/jte/compiler/ContentProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public void process() {
push(Mode.Raw);
} else if (regionMatches("@endraw") && currentMode == Mode.Raw) {
pop();
} else if (regionMatches("<%--") && currentMode == Mode.Content) {
push(Mode.Comment);
} else if (regionMatches("--%>") && currentMode == Mode.Comment) {
pop();
}
}

Expand Down Expand Up @@ -83,7 +79,6 @@ private enum Mode {
Code,
Content,
Raw,
Comment,
;

boolean isContentBlockAllowed() {
Expand Down
10 changes: 3 additions & 7 deletions jte/src/main/java/gg/jte/compiler/TemplateParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -148,9 +148,7 @@ private void doParse(int startingDepth) {
} else if (currentMode == Mode.Comment) {
if (regionMatches("--%>")) {
pop();
if (currentMode == Mode.Text) {
lastIndex = i + 1;
}
lastIndex = i + 1;
}
} else if (currentMode == Mode.HtmlComment) {
if (regionMatches("-->")) {
Expand Down Expand Up @@ -405,7 +403,7 @@ private int getCurrentTemplateLine() {
}

private boolean isCommentAllowed() {
return currentMode == Mode.Text || currentMode == Mode.Content;
return currentMode == Mode.Text;
}

private boolean isParamOrImportAllowed() {
Expand Down Expand Up @@ -623,9 +621,7 @@ private void extractHtmlCodePart() {

private void extractComment(Mode mode, int startIndex) {
if (paramsComplete || areParamsComplete(startIndex)) {
if (currentMode == Mode.Text) {
extractTextPart(startIndex, mode);
}
extractTextPart(startIndex, mode);
}
push(mode);
}
Expand Down
12 changes: 0 additions & 12 deletions jte/src/test/java/gg/jte/TemplateEngineTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -791,18 +791,6 @@ void htmlCommentInPlainTemplate() {
thenOutputIs("Hello<!--This is an HTML comment--> World");
}

@Test
void commentWithBacktickInContentBlock() {
givenTemplate("""
!{var content = @`<%--`--%>Hello there!`;}
${content}
""");
thenOutputIs("""
Hello there!
""");
}

@Test
void importInCss() {
givenTemplate("<style type=\"text/css\" rel=\"stylesheet\" media=\"all\">\n" +
Expand Down

0 comments on commit 818beb7

Please sign in to comment.