Spaces around { and before } in string interpolation #66

Closed
amiel opened this Issue Jan 6, 2012 · 8 comments

Comments

Projects
None yet
5 participants
@amiel
Contributor

amiel commented Jan 6, 2012

So far this guide states that:

Use spaces around operators, after commas, colons and semicolons, around { and before }.

However, all examples using string interpolation do not use spaces ("Example #{self.number}").

Because of the previous statement, I've started using a string interpolation style like this:

"Example #{ self.number }"

Obviously, there cannot be a space before { and it cannot required to have one after },
as that is part of the string. However, I find it nice to have the visual distinction that there is code
between { and }.

Thoughts?

@philtr

This comment has been minimized.

Show comment Hide comment
@philtr

philtr Jan 6, 2012

+1

I've started doing this myself as well; it more clearly sets the code apart from the string.

philtr commented Jan 6, 2012

+1

I've started doing this myself as well; it more clearly sets the code apart from the string.

@bbatsov

This comment has been minimized.

Show comment Hide comment
@bbatsov

bbatsov Jan 10, 2012

Owner

I kind of like the idea. I'll contemplate a bit on it.

Owner

bbatsov commented Jan 10, 2012

I kind of like the idea. I'll contemplate a bit on it.

@amiel

This comment has been minimized.

Show comment Hide comment
@amiel

amiel Jan 10, 2012

Contributor

Cool, try it out for a bit. At first (just like any other change), it looks a little weird, but I think you'll find it easier to read after you get comfortable with it.

I'd be happy to send in a pull request if it'd be appreciated...

Contributor

amiel commented Jan 10, 2012

Cool, try it out for a bit. At first (just like any other change), it looks a little weird, but I think you'll find it easier to read after you get comfortable with it.

I'd be happy to send in a pull request if it'd be appreciated...

@adrianpike

This comment has been minimized.

Show comment Hide comment
@adrianpike

adrianpike Jan 10, 2012

I've been finding myself having to hunt #{}s in strings, I really like this distinction.

I've been finding myself having to hunt #{}s in strings, I really like this distinction.

@Confusion

This comment has been minimized.

Show comment Hide comment
@Confusion

Confusion Mar 13, 2012

Do you know of any well known projects that use this convention? I don't believe I've ever encountered it and I think it is a thing that could typically jeopardize adoption of this style guide. I think it would be better to allow/suggest it, but not require it.

Do you know of any well known projects that use this convention? I don't believe I've ever encountered it and I think it is a thing that could typically jeopardize adoption of this style guide. I think it would be better to allow/suggest it, but not require it.

@bbatsov

This comment has been minimized.

Show comment Hide comment
@bbatsov

bbatsov Mar 13, 2012

Owner

My thought's exact.

Owner

bbatsov commented Mar 13, 2012

My thought's exact.

@amiel

This comment has been minimized.

Show comment Hide comment
@amiel

amiel Mar 13, 2012

Contributor

@Confusion I'm trying to remember where I saw this that turned me on to the idea.

I'm in favor of suggesting but not requiring it.

Contributor

amiel commented Mar 13, 2012

@Confusion I'm trying to remember where I saw this that turned me on to the idea.

I'm in favor of suggesting but not requiring it.

@bbatsov

This comment has been minimized.

Show comment Hide comment
@bbatsov

bbatsov Apr 20, 2012

Owner

Ok, prepare a pull request that suggests it and I'll pull it upstream.

Owner

bbatsov commented Apr 20, 2012

Ok, prepare a pull request that suggests it and I'll pull it upstream.

amiel pushed a commit to amiel/ruby-style-guide that referenced this issue Apr 20, 2012

amiel pushed a commit to amiel/ruby-style-guide that referenced this issue Apr 20, 2012

@bbatsov bbatsov closed this in 86cedda Apr 21, 2012

JuanitoFatas referenced this issue in JuanitoFatas/ruby-style-guide Apr 25, 2012

marocchino pushed a commit to marocchino/ruby-style-guide that referenced this issue Aug 11, 2015

shyouhei pushed a commit to shyouhei/ruby-style-guide that referenced this issue Nov 11, 2015

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