I am looking into HAML and am trying to convert one of my ERB templates to see what I think of it. Everything was going pretty well until I got to the following snippet: <div class="<%= t.done ? "task done": "task" %>"> <p class="title"><%= h(t.description)%></p> </div> How would you do this in HAML? (I know how to do the middle line) Thanks in advance, Alan --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 14, 2008, at 8:28 PM, Alan Smith wrote:> I am looking into HAML and am trying to convert one of my ERB > templates to see what I think of it. Everything was going pretty > well until I got to the following snippet: > > <div class="<%= t.done ? "task done": "task" %>"> > <p class="title"><%= h(t.description)%></p> > </div> > > How would you do this in HAML? (I know how to do the middle line) > > > Thanks in advance, > > AlanIt works pretty much the same way: %div{:class => t.done ? "task done" : "task"} %p.title= h(t.description) Check out the Haml Google Group: http://groups.google.com/group/haml --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alan Smith
2008-Feb-15 14:58 UTC
Re: HAML question - conditional multiple classes on a div
Thanks!! On Fri, Feb 15, 2008 at 12:36 AM, s.ross <cwdinfo-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > On Feb 14, 2008, at 8:28 PM, Alan Smith wrote: > > > I am looking into HAML and am trying to convert one of my ERB > > templates to see what I think of it. Everything was going pretty > > well until I got to the following snippet: > > > > <div class="<%= t.done ? "task done": "task" %>"> > > <p class="title"><%= h(t.description)%></p> > > </div> > > > > How would you do this in HAML? (I know how to do the middle line) > > > > > > Thanks in advance, > > > > Alan > > It works pretty much the same way: > > %div{:class => t.done ? "task done" : "task"} > %p.title= h(t.description) > > Check out the Haml Google Group: http://groups.google.com/group/haml > > > > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---