Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ protected CharSequence safeApply(final Object context, final Options options) {
join {
@Override
public Object apply(final Object context, final Options options) {
if (options.isFalsy(context)) {
if (options.isFalsy(context) && !(context instanceof CharSequence)) {
return "";
}
return safeApply(context, options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,37 @@ public void joinValues() throws IOException {
"{{{join \"6\" 7 n8 \"-\"}}}", $("n8", 8), $("join", StringHelpers.join), "6-7-8");
}

@Test
public void joinEmptyStringValues() throws IOException {
shouldCompileTo(
"{{{join \"\" \"7\" 8 \"-\" prefix='<' suffix='>'}}}",
$,
$("join", StringHelpers.join),
"<-7-8>");
}

@Test
public void joinEmptyStringInSubexpression() throws IOException {
shouldCompileTo(
"{{#*inline \"anchor\"}}{{anchorId}}{{/inline}}"
+ "{{> anchor anchorId=(join anchorId jsonPathPiece.snakeCase \"\")}}",
$("anchorId", "", "jsonPathPiece", $("snakeCase", "user_name")),
$("join", StringHelpers.join),
"user_name");
}

@Test
public void joinEmptyCharSequence() throws IOException {
shouldCompileTo(
"{{join this \"tail\" \"\"}}", new StringBuilder(), $("join", StringHelpers.join), "tail");
}

@Test
public void joinEmptyStringInBlock() throws IOException {
shouldCompileTo(
"{{#join \"\" \"tail\" \"\"}}{{/join}}", $, $("join", StringHelpers.join), "tail");
}

@Test
public void joinWithPrefixAndSuffix() throws IOException {
shouldCompileTo(
Expand Down
Loading