Skip to content

Commit

Permalink
Fixed #44 throws NullPointerException when trim.directive.comments=true
Browse files Browse the repository at this point in the history
  • Loading branch information
subchen committed Dec 10, 2013
1 parent d724361 commit 2745f5e
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/main/java/jetbrick/template/parser/code/TextCode.java
Expand Up @@ -32,6 +32,10 @@ public TextCode(String id, String text) {
}

public void trimEmptyLine(boolean trimLeft, boolean trimRight, boolean keepLeftNewLine) {
if (text == null || text.length() == 0) {
return;
}

int lpos = 0;
if (trimLeft) {
int len = text.length();
Expand Down Expand Up @@ -82,7 +86,9 @@ public void trimEmptyLine(boolean trimLeft, boolean trimRight, boolean keepLeftN
}

public void trimComments(boolean trimLeft, boolean trimRight, String prefix, String suffix) {
if (text == null) return;
if (text == null || text.length() == 0) {
return;
}

int lpos = 0;
int text_len = text.length();
Expand Down Expand Up @@ -145,7 +151,9 @@ public void trimComments(boolean trimLeft, boolean trimRight, String prefix, Str
}

public void trimLastNewLine() {
if (text == null) return;
if (text == null || text.length() == 0) {
return;
}

int length = text.length();
if (text.charAt(length - 1) == '\n') {
Expand Down

0 comments on commit 2745f5e

Please sign in to comment.