Skip to content

Commit 0af1d54

Browse files
committed
Merge pull request #557 from sethkinast/fix-format
Fix the output of format (whitespace-only) blocks inside inline partials
2 parents 6fffa4b + 4cbe3a4 commit 0af1d54

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

lib/compiler.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@
233233
},
234234

235235
format: function(context, node) {
236-
return '.w(' + escape(node[1] + node[2]) + ')';
236+
return '.w(' + escape(node[1]) + ')';
237237
},
238238

239239
reference: function(context, node) {

test/jasmine-test/spec/coreTests.js

+33-1
Original file line numberDiff line numberDiff line change
@@ -1776,7 +1776,39 @@ var coreTests = [
17761776
{
17771777
name: "whitespace test",
17781778
tests: [
1779-
{
1779+
{
1780+
name: "whitespace on: whitespace-only template",
1781+
source: "\n ",
1782+
context: {},
1783+
expected: "\n ",
1784+
message: "whitespace on: whitespace-only template is preserved",
1785+
config: { whitespace: true }
1786+
},
1787+
{
1788+
name: "whitespace off: whitespace-only template",
1789+
source: "\n ",
1790+
context: {},
1791+
expected: "",
1792+
message: "whitespace off: whitespace-only template is removed",
1793+
config: { whitespace: false }
1794+
},
1795+
{
1796+
name: "whitespace on: whitespace-only block",
1797+
source: "{<foo}\n{/foo}{+foo/}",
1798+
context: {},
1799+
expected: "\n",
1800+
message: "whitespace on: whitespace-only block is preserved",
1801+
config: { whitespace: true }
1802+
},
1803+
{
1804+
name: "whitespace off: whitespace-only block",
1805+
source: "{<foo}\n{/foo}{+foo/}",
1806+
context: {},
1807+
expected: "",
1808+
message: "whitespace off: whitespace-only block is removed",
1809+
config: { whitespace: false }
1810+
},
1811+
{
17801812
name: "whitespace off: multiline text block runs together",
17811813
source: ["<p>",
17821814
" foo bar baz",

0 commit comments

Comments
 (0)