Scenario: one-line Handlebars partial used in an inline element:
Handlebars template:
<a href="#section">{{> partial}}Label</a>
Partial:
<svg class="icon" viewBox="0 0 65 65"><use xlink:href="#icon"></use></svg>
Compilation result:
<a href="#section"><svg class="icon" viewBox="0 0 65 65"><use xlink:href="#icon"></use></svg>
Label</a>
As you see, partial es across with the newline. There's no newline in the file.
Scenario: one-line Handlebars partial used in an inline element:
Handlebars template:
<a href="#section">{{> partial}}Label</a>
Partial:
<svg class="icon" viewBox="0 0 65 65"><use xlink:href="#icon"></use></svg>
Compilation result:
<a href="#section"><svg class="icon" viewBox="0 0 65 65"><use xlink:href="#icon"></use></svg>
Label</a>
As you see, partial es across with the newline. There's no newline in the file.
Share Improve this question asked Jun 19, 2014 at 22:52 Ain TohvriAin Tohvri 3,0356 gold badges34 silver badges51 bronze badges 2- 1 Are you prepiling ur templates? Maybe BOM character is getting added. – blessanm86 Commented Jun 20, 2014 at 7:12
-
Checked against it, used
:set nobomb
and resaved (in Vim), still the same. – Ain Tohvri Commented Jun 20, 2014 at 9:13
2 Answers
Reset to default 5It's on the handlebarsjs., but not documented well enough (for me);
after a half an hour of struggling wandering where exactly am I supposed to set this "~"
{{#each arrayOfItems ~}}
<div>
{{~> item ~}}
</div>
{{~each}}
aaand, works like a charm for me:)
(handlebars-express3 on Node.js)
The issue was caused by the Vim's EOL management.
To prevent newline appearing after the Handlebars pilation, change Vim configuration (.vimrc
) to include:
au BufWritePre * :set binary | set noeol
au BufWritePost * :set nobinary | set eol