What version are you using? I was looking at some of the
inconsistencies in how object_ref overrides the other attributes. It
appends object ref attributes to class specified with css style
attributes. ie:
%div.className[item] => <div class="className item">
Which is what you want. Unfortunately, you need a conditional, and
classes specified in the attribute hash smash over attributes from the
object ref, as you've seen.
Nathan, I assumed this was an unintentional quirk in the
implementation? Seems like it is reordering the merges and passing
all the existing attributes to the object ref stuff that would fix his
problem, yes? As in %div{:class => condition ? "selected" : ""}
[item] would work fine, special case of supplying nil is
unnecessary? (Though that will work also since with all the to_s'ing,
the nil turns into a "" also in the current version)
-Tom
On Jun 5, 3:52 pm, Sean Cribbs <[EMAIL PROTECTED]> wrote:
> Thanks for your quick response, Nathan. It seems that works... mostly.
> I don't want to obliterate the class if the condition is false, just not
> _add_ the "selected" class. So basically, I want this:
>
> condition is false:
>
> <div class="item" id="item_19">
>
> condition is true:
>
> <div class="item selected" id="item_19">
>
> Sean
>
> Nathan Weizenbaum wrote:
> > No, there isn't. I may have
>
> > %div{:class => condition ? "selected" : nil}[item]
>
> > Work like that.
>
> > - Nathan
>
> > On 6/5/07, *Sean Cribbs * <[EMAIL PROTECTED]
> > <mailto:[EMAIL PROTECTED]>> wrote:
>
> > Is there a way to do what I'm trying to do here that preserves the
> > "SimplyHelpful" auto-id-and-class stuff and also conditionally adds a
> > class?
>
> > %div{:class => condition ? "selected" : ""}[item]
>
> > I can't figure out a way to do it cleanly without resorting to
> > generating the default id and class manually.
>
> > Cheers,
>
> > Sean
> > p.s. RadiantCMS now has Sass:
> > http://dev.radiantcms.org/radiant/browser/trunk/extensions/sass_filter
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Haml" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/haml?hl=en
-~----------~----~----~----~------~----~------~--~---