wix-incubator / react-templates

Light weight templates for react
https://wix.github.io/react-templates
MIT License
2.82k stars 207 forks source link

proper trimming of trailing white spaces #219

Open nippur72 opened 7 years ago

nippur72 commented 7 years ago

React templates should properly trim trailing spaces when the text is on a different line respect to the enclosing tags. E.g.

<div>
   Hello
</div>

should result in

<div>Hello</div>

when compiled.

Instead, as of today, it's rendered as:

<div>  \n Hello \n</div>     <!-- when normalizeHtmlWhiteSpace==false -->
<div> Hello </div>           <!-- when normalizeHtmlWhiteSpace==true, notice the trailing extra spaces -->

I think we should align the behavior to what JSX compilers do, that is trim trailing spaces and newlines if the text spans over different lines. I can submit a PR if anyone is interested.