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

Explain ERB space removal. #16790

Merged
merged 1 commit into from Sep 16, 2014

Conversation

cirosantilli
Copy link
Contributor

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

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
Copy link
Member

vijaydev commented Sep 3, 2014

I'm for linking to ERB docs.

@zzak
Copy link
Member

zzak commented Sep 3, 2014

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

@cirosantilli
Copy link
Contributor Author

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

@vijaydev
Copy link
Member

vijaydev commented Sep 3, 2014

@cirosantilli yes please.

@zzak
Copy link
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 -%>

@zzak
Copy link
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
Copy link
Contributor Author

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
Copy link
Member

zzak commented Sep 3, 2014

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

@cirosantilli
Copy link
Contributor Author

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
Copy link
Member

vijaydev commented Sep 9, 2014

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

@cirosantilli
Copy link
Contributor Author

How about the current version?

@seuros
Copy link
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.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give an example where they are different?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 explain-erb-space-removal branch September 16, 2014 14:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants