Skip to content

Commit 3b12ca3

Browse files
committed
feat(Handlebars): block whitespace control
1 parent 6f5bf3d commit 3b12ca3

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/lib/Support/Handlebars.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2431,7 +2431,14 @@ parseBlock(
24312431
}
24322432

24332433
// ==============================================================
2434-
// Apply close tag whitespace control
2434+
// Apply open tag whitespace control to block
2435+
// ==============================================================
2436+
if (tag.removeRWhitespace) {
2437+
fnBlock = trim_lspaces(fnBlock);
2438+
}
2439+
2440+
// ==============================================================
2441+
// Apply close tag whitespace control after block
24352442
// ==============================================================
24362443
if (closeTag.removeRWhitespace) {
24372444
templateText = trim_lspaces(templateText);

src/test/lib/Support/Handlebars.cpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1689,6 +1689,15 @@ partial_blocks()
16891689
"{{#>nested}}1{{#>nested}}2{{/nested}}3{{/nested}}") ==
16901690
"123");
16911691
}
1692+
1693+
// should remove whitespace from nested partial blocks
1694+
{
1695+
hbs.registerPartial("nested", "{{> @partial-block }}");
1696+
BOOST_TEST(
1697+
hbs.render(
1698+
"{{#>nested~}} 1 {{~#>nested~}} 2 {{~/nested ~}} 3 {{~/nested}}") ==
1699+
"123");
1700+
}
16921701
}
16931702

16941703
void

0 commit comments

Comments
 (0)