Quoting strings

3 views
Skip to first unread message

Andrew Vit

unread,
Nov 21, 2009, 3:38:48 PM11/21/09
to compas...@googlegroups.com
Hi group,

This was recently brought up in another syntax thread, but I think it warrants its own discussion. How would you quote the following?

I started out with a string with double-quotes that I pasted into my sass file. In the end the syntax forced me to change them to single quotes or else I’d have to escape them. Do I need to use backslashes to escape double quotes or is there some behaviour between single and double quotes that I’m just not getting?

I’m using the current haml-edge 2.3.88 gem.

!lucida_font_stack = "Lucida Grande", Verdana, sans-serif
Implicit strings have been deprecated and will be removed in version 2.4.
'serif' was not quoted. Please add double quotes (e.g. "serif").

!lucida_font_stack = '"Lucida Grande", Verdana, sans-serif'
(outputs the whole thing within single quotes: one long font name)

!lucida_font_stack = "\"Lucida Grande\", Verdana, sans-serif"
(works correctly, for double quoted strings in output)

!lucida_font_stack = "'Lucida Grande', Verdana, sans-serif"
(works correctly, for single quoted strings in output)

Thanks,
Andrew Vit

Nathan Weizenbaum

unread,
Nov 21, 2009, 3:51:16 PM11/21/09
to compas...@googlegroups.com
I would use

!lucida_font_stack = '"Lucida Grande", Verdana, sans-serif'

This should work as expected. The only difference between single and double quotes is which sort of quote needs to be escaped within the strings.


--

You received this message because you are subscribed to the Google Groups "Compass" group.
To post to this group, send email to compas...@googlegroups.com.
To unsubscribe from this group, send email to compass-user...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/compass-users?hl=.



Andrew Vit

unread,
Nov 22, 2009, 2:20:05 AM11/22/09
to compas...@googlegroups.com
Hi Nathan,

As I noted, I tried it that way. It outputs like this:

font-family: 'Lucida Grande, Verdana, sans-serif’

Which leads the browser to treat it as one long font name. (Note the double quotes are stripped out too). I can work around it obviously, but that’s the reason I’m asking, because it’s somewhat confusing… :-(

Andrew Vit

Nathan Weizenbaum

unread,
Nov 22, 2009, 4:11:12 PM11/22/09
to compas...@googlegroups.com
Sorry, I had forgotten that single quotes are only in the master branch. For released versions, backslash-escaping the quotes is the way to go.
Reply all
Reply to author
Forward
0 new messages