Open zorbash opened 11 years ago
The code causing the above is https://github.com/sstephenson/sprockets/blob/master/lib/sprockets/directive_processor.rb#L80
I suppose you could trim it in handlebars_assets as well, but that might also cause unexpected results (in certain cases). This is probably a really rare case though.
why not just do <p>no new line after this phrase</p>
; which fixes it for your example I believe ? potentially?
but maybe your toy example does not actually fully clarify the issue.
I agree that adding specific markup in a template may bypass the problem. But the thing here is that the template source is altered in a way that the same template source would yield different output when compiled in the browser.
So... I would love to just strip the whitespace, however in the case that someone ACTUALLY wants the whitespace then it would break that case... I also do not want to re-grab the body that tilt has already grabbed... hmmm this will plague all template compilers.
However there is a simple work-around in the case the user wants the whitespace (add two-newlines).
@Zorbash, Agree with the trim at most one new-line approach?
@AlexRiedler Yes, if someone (for compatibility reasons perhaps) still wants the extra newline, two newlines should be inserted for this newline to be appended. Are you on it?
Yup, on it! (I think it may already be done on my branch; but still needs some verification with how HAML and SLIM works in this case).
When using the require directive to embed a template file in another file the initial template source is altered (a newline is appended).
It may seem harmless but it may cause undesired and visible effects.
Example.
In the example above the text node will be
instead of
"no newline after this phrase"
We have currently decided to trim the compiled template output before using it with text nodes. But is there another way around?