Reputation: 3035
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 comes across with the newline. There's no newline in the file.
Upvotes: 4
Views: 3844
Reputation: 2737
It's on the handlebarsjs.com, 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)
Upvotes: 5
Reputation: 3035
The issue was caused by the Vim's EOL management.
To prevent newline appearing after the Handlebars compilation, change Vim configuration (.vimrc
) to include:
au BufWritePre * :set binary | set noeol
au BufWritePost * :set nobinary | set eol
Upvotes: 1