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

Explain ERB space removal. #16790

Merged
merged 1 commit into from Sep 16, 2014

Conversation

Projects
None yet
5 participants
@cirosantilli
Contributor

cirosantilli commented Sep 3, 2014

The current phrase about space removal is misleading, and too hard to understand without an example. I propose that we either:

  • explain it better
  • remove it completely and let people look up erubis docs now that we linked to them at #16774

It is misleading because:

  • spaces are only removed if the entire line contains only whitespaces
  • -%> is not interchangeable with %> when using the equals sign <%= %>.

If you think the new explanation is too long, we can consider removing everything after "The line is not removed when" as that use case is less common: at least the new information won't be ambiguous and will have a clarifying example.

@vijaydev

This comment has been minimized.

Member

vijaydev commented Sep 3, 2014

I'm for linking to ERB docs.

@zzak

This comment has been minimized.

Member

zzak commented Sep 3, 2014

👍 for linking, I'm weary to add this much detail to the overview of a constant.

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 3, 2014

Shall we just remove the line then? We already have the link to erubis.

@vijaydev

This comment has been minimized.

Member

vijaydev commented Sep 3, 2014

@cirosantilli yes please.

@zzak

This comment has been minimized.

Member

zzak commented Sep 3, 2014

Well, idk

This line exists to explain why there are different tags available, from the line above:

You trigger ERB by using embeddings such as <% %>, <% -%>, and <%= %>. The <%= %> tag set is used when you want output. Consider the following loop for names:

There is a very subtle but obvious difference between them, so it would be nice to leave a small statement that warns the user about -%>

@cirosantilli cirosantilli force-pushed the cirosantilli:explain-erb-space-removal branch Sep 3, 2014

@zzak

This comment has been minimized.

Member

zzak commented Sep 3, 2014

I am 👎

There isn't even anything on the erubis docs that mentions -%>..

But there is mention of trimming whitespace, except using a different tag:

Spaces around '<% %>' are trimmed automatically only when '<%' is at the beginning of line and '%>' is at the end of line.

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 3, 2014

That is true. I came to those conclusions after a lot of experimenting. The docs there are not very complete. We could patch their docs.

@zzak

This comment has been minimized.

Member

zzak commented Sep 3, 2014

There is even an open ticket on erubis for this: kwatch/erubis#4

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 5, 2014

Ping: what will we do about this?

I see the following options:

  • remove the line
  • clarify the line without an example (the exact phrase is not too short, and too hard to understand without an example)
  • ... something else?

We can then patch erubis docs if necessary.

@vijaydev

This comment has been minimized.

Member

vijaydev commented Sep 9, 2014

Clarifying without going into too much detail will be ideal imo.

@cirosantilli cirosantilli force-pushed the cirosantilli:explain-erb-space-removal branch to 700ec89 Sep 11, 2014

@cirosantilli

This comment has been minimized.

Contributor

cirosantilli commented Sep 11, 2014

How about the current version?

@seuros

This comment has been minimized.

Member

seuros commented Sep 14, 2014

ping @zzak

@seuros seuros added the docs label Sep 14, 2014

@seuros seuros added this to the 4.2.0 milestone Sep 16, 2014

@@ -33,7 +33,9 @@ module ActionView #:nodoc:
#
# If you absolutely must write from within a function use +concat+.
#
# <%- and -%> suppress leading and trailing whitespace, including the trailing newline, and can be used interchangeably with <% and %>.
# When on a line that only contains whitespaces except for the tag, <% %> suppress leading and trailing whitespace,
# including the trailing newline. <% %> and <%- -%> are the same.

This comment has been minimized.

@rafaelfranca

rafaelfranca Sep 16, 2014

Member

I don't think this is true. %> and -%> and different.

This comment has been minimized.

@cirosantilli

cirosantilli Sep 16, 2014

Contributor

Can you give an example where they are different?

This comment has been minimized.

@rafaelfranca

rafaelfranca Sep 16, 2014

Member

It is only in the <%= case. So this is right.

@rafaelfranca rafaelfranca removed this from the 4.2.0 milestone Sep 16, 2014

rafaelfranca added a commit that referenced this pull request Sep 16, 2014

@rafaelfranca rafaelfranca merged commit 1bdb233 into rails:master Sep 16, 2014

@cirosantilli cirosantilli deleted the cirosantilli:explain-erb-space-removal branch Sep 16, 2014

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment