Skip to content

Commit

Permalink
feat(Handlebars): block whitespace control
Browse files Browse the repository at this point in the history
  • Loading branch information
alandefreitas committed Nov 20, 2024
1 parent 6f5bf3d commit 3b12ca3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2431,7 +2431,14 @@ parseBlock(
}

// ==============================================================
// Apply close tag whitespace control
// Apply open tag whitespace control to block
// ==============================================================
if (tag.removeRWhitespace) {
fnBlock = trim_lspaces(fnBlock);
}

// ==============================================================
// Apply close tag whitespace control after block
// ==============================================================
if (closeTag.removeRWhitespace) {
templateText = trim_lspaces(templateText);
Expand Down
9 changes: 9 additions & 0 deletions src/test/lib/Support/Handlebars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,15 @@ partial_blocks()
"{{#>nested}}1{{#>nested}}2{{/nested}}3{{/nested}}") ==
"123");
}

// should remove whitespace from nested partial blocks
{
hbs.registerPartial("nested", "{{> @partial-block }}");
BOOST_TEST(
hbs.render(
"{{#>nested~}} 1 {{~#>nested~}} 2 {{~/nested ~}} 3 {{~/nested}}") ==
"123");
}
}

void
Expand Down

0 comments on commit 3b12ca3

Please sign in to comment.