Using a constant as an ID, passed in from a mixin argument

1 view
Skip to first unread message

Lorin Tackett

unread,
Nov 13, 2009, 6:41:04 PM11/13/09
to ha...@googlegroups.com
I did this successfully with classes, but with ID's it chokes,
presumably on the syntax.

in application.sass I have

+layout(default)
+layout(three-column)
+layout(two-column)

in _layouts.sass I have

= layout(!name = false)
!layout_selector = "##{!name}"

@if !name == "default
body
#primary
+column(18)
#primary
+column(8, true)
@else
body#{layout_selector}
@if !name == "three-column"
#primary
+column(8)
#secondary
+column(8)
#tertiary
+column(8, true)
@if !name == "one-column"
#primary
+column(24, true)

Is there any way to do this?

Lorin Tackett

unread,
Nov 13, 2009, 6:45:18 PM11/13/09
to ha...@googlegroups.com
Oops, forgot the bang on the !layout_selector... but only in my code
example...

@else
body#{!layout_selector}
@if !name == "three-column"

There is no error, the output I get is the rules for each layout
section, but without the body#layout_selector selector... sass just
removes it and outputs starting at #primary.

Chris Eppstein

unread,
Nov 13, 2009, 6:59:37 PM11/13/09
to ha...@googlegroups.com
Looks like you found a bug. here's a few more (simpler) cases of weirdness:

>>> Sass
!argument = "asdf"
!bar = "##{!argument}"
body#{!bar}
  #foo
    color: blue
=======
body##{!argument} #foo {
  color: blue; }
<<<< CSS

>>>> Sass
!argument = "asdf"
!bar = "#" + !argument
body#{!bar}
  #foo
    color: blue
========
body"#"asdf #foo {
  color: blue; }
<<<< CSS

Plus I get
DEPRECATION WARNING:
On line 2, character 8
Implicit strings have been deprecated and will be removed in version 2.4.
'"#"' was not quoted. Please add double quotes (e.g. ""#"").


$ sass -i
>> !bar = "#"
DEPRECATION WARNING:
On line 1, character 8
Implicit strings have been deprecated and will be removed in version 2.4.
'"#"' was not quoted. Please add double quotes (e.g. ""#"").


--

You received this message because you are subscribed to the Google Groups "Haml" group.
To post to this group, send email to ha...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/haml?hl=.



Lorin Tackett

unread,
Nov 13, 2009, 7:26:08 PM11/13/09
to ha...@googlegroups.com
The workaround is actually the better way to do it anyway...

Chris grokked through this on IM.

>>> Sass
!argument = "asdf"
body##{!argument}
  #foo
    color: blue
========
body#asdf #foo {
  color: blue; }
<<< CSS

Thanks Chris!

Nathan Weizenbaum

unread,
Nov 13, 2009, 9:00:56 PM11/13/09
to ha...@googlegroups.com
I've fixed this in revision 090aec3. Thanks for the report!
Reply all
Reply to author
Forward
0 new messages