nanohtml
nanohtml copied to clipboard
implicit/explicit whitespace
When working with a more strict layout, whitespace between elements can cause trouble. For example, if I have a couple of spans that need to be flush against each other, there can't be any whitespace between the span tags in the generated HTML. Unfortunately, bel (or hyperx?) preserves the whitespace from the input.
bel`
<p>
<span>one</span>
<span>two</span>
</p>
`.toString()
generates:
<p>\n <span>one</span>\n <span>two</span>\n </p>
To work around this issue, I'd have to
bel`
<p>
<span>one</span><span>two</span>
</p>
`.toString()
Which isn't ideal, especially when multiple tags are involved or if they have attributes.
I like the way React deals with this issue: https://facebook.github.io/react/blog/2014/02/20/react-v0.9.html#jsx-whitespace