Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Control token for *preserving* whitespace #264

Open
osyvokon opened this issue Oct 26, 2023 · 1 comment
Open

Control token for *preserving* whitespace #264

osyvokon opened this issue Oct 26, 2023 · 1 comment

Comments

@osyvokon
Copy link

osyvokon commented Oct 26, 2023

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

  1. Put an extra new line after the tag, but this doesn't look good:
    One
    <%= num2str(1 + 1) %>
    
    Three
    
  2. 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!

@nebrelbug
Copy link
Collaborator

This is an intriguing idea! I'll ask people what they think in the Eta Discord.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants