Closed JBRector closed 10 years ago
I escaping makes sense, complex dom structures should be a template not a variable string. A complex structure is the only time it makes sense.
Your example also makes me think that we don't outline special characters in strings. @LukeAskew, your thoughts? This comes a lot stuff like trademarks, quotes, ampersand, etc
I initially had single quotes, but we chose double quotes because it is more consistent with other languages.
@JBRector your example shows double quotes when defining an html element attribute. Are there any other cases for double quotes in a string?
I ask because, typically, we are trying to move away from mixing html and js (or at least html inside .js files).
"we are trying to move away from mixing html and js (or at least html inside .js files)."
completely agree!
If dom structures are needed, you can easily write them in JS which makes it easy to read too
OK, fair enough. I don't really think there is another reason I can offer other than it's my personal preference.
I'd like to revisit this issue.
I'm finding that single quotes is becoming more standard in JavaScript. I'm finding myself switching to single quotes often if I want to contribute to projects, specifically node.js projects as single quotes is the recommended standard.
Looking back, our initial reasoning that "double quotes is more standard" may be a little thin.
Many popular JS app frameworks also mix html strings in JS code, so single quotes are preferred for consistency sake.
Here are some interesting discussions about single vs. double:
Just keep in mind that JSON requires double quotes. That being said, I typically only use single quotes myself. Faster to type :-)
On Thu, Mar 27, 2014 at 9:14 AM, Matthew Toledo matthew.toledo@gmail.comwrote:
Just keep in mind that JSON requires double quotes. That being said, I only use double quotes when I'm putting HTML in a string, or when I need to output a control character.
Single quotes for HTML because valid HTML requires attributes be encased in double quotes and I don't want to clutter stuff with escape slashes.
On Wed, Mar 26, 2014 at 10:29 AM, Luke Askew notifications@github.comwrote:
I'd like to revisit this issue.
I'm finding that single quotes is becoming more standard in JavaScript. I'm finding myself switching to single quotes often if I want to contribute to projects, specifically node.js projects as single quotes is the recommended standard http://nodeguide.com/style.html#quotes.
Looking back, our initial reasoning that "double quotes is more standard" may be a little thin.
Many popular JS app frameworks also mix html strings in JS code, so single quotes are preferred for consistency sake.
Here are some interesting discussions about single vs. double:
airbnb/javascript#110https://github.com/airbnb/javascript/issues/110
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Strings#Strings
Reply to this email directly or view it on GitHubhttps://github.com/resource/Front-End-Standards/issues/26#issuecomment-38689766 .
I have always supported single quotes and will continue to do so (note: you can type it faster).
On Mar 27, 2014, at 9:35 AM, Matthew Toledo notifications@github.com wrote:
Ooops. Type-o in last email. Ignore it all... Take 2:
Just keep in mind that JSON requires double quotes. That being said, I typically only use single quotes myself. Faster to type :-)
On Thu, Mar 27, 2014 at 9:14 AM, Matthew Toledo matthew.toledo@gmail.comwrote:
Just keep in mind that JSON requires double quotes. That being said, I only use double quotes when I'm putting HTML in a string, or when I need to output a control character.
Single quotes for HTML because valid HTML requires attributes be encased in double quotes and I don't want to clutter stuff with escape slashes.
On Wed, Mar 26, 2014 at 10:29 AM, Luke Askew notifications@github.comwrote:
I'd like to revisit this issue.
I'm finding that single quotes is becoming more standard in JavaScript. I'm finding myself switching to single quotes often if I want to contribute to projects, specifically node.js projects as single quotes is the recommended standard http://nodeguide.com/style.html#quotes.
Looking back, our initial reasoning that "double quotes is more standard" may be a little thin.
Many popular JS app frameworks also mix html strings in JS code, so single quotes are preferred for consistency sake.
Here are some interesting discussions about single vs. double:
- airbnb/javascript#110https://github.com/airbnb/javascript/issues/110
http://google-styleguide.googlecode.com/svn/trunk/javascriptguide.xml?showone=Strings#Strings
Reply to this email directly or view it on GitHubhttps://github.com/resource/Front-End-Standards/issues/26#issuecomment-38689766 .
— Reply to this email directly or view it on GitHub.
I think single quotes make more sense for strings. There will be occasions where you will need to use a double quote in the string itself.
I know you can escape them, but that would add superfluous code IMO. This way seems more simple.