Control token for *preserving* whitespace
osyvokon opened this issue · comments
Problem
The default for whitespace control is to trim newlines after the tag. This is sensible in most cases. However, sometimes I'd like to preserve the newline. For example:
One
<%= num2str(1 + 1) %>
Three
This is expected to be rendered to
One
Two
Three
but the default output is
One
Two Three
Describe the solution you'd like
Introduce a tag that preserves whitespace overruling global settings. Something like |%>
. The example above would become this:
One
<%= num2str(1 + 1) |%>
Three
Describe alternatives you've considered
- Put an extra new line after the tag, but this doesn't look good:
One <%= num2str(1 + 1) %> Three
- Set
autoTrim: false
, but that requires trimming whitespace manually (by using<%-
and-%>
). Again, for the most part I'm happy with autoTrim, but in some rare cases need to override it.
Let me know if you think this is a sensible feature. If so, I can open a pull request.
Thanks!
This is an intriguing idea! I'll ask people what they think in the Eta Discord.