Why not use the if? - if foo.subject.present? %div Hello
This is clean and readable for all situations 2009/7/19 grimen <[email protected]> > > Agree. Create a helper like: > > = conditional_tag(:div, :if => foo.subject.present?) do > = "Hello" > > > grimen > > On Jul 18, 7:32 pm, Nathan Weizenbaum <[email protected]> wrote: > > I feel like, in this case, the more explicit way of writing it is best. > If > > we do add the language feature, most people won't know about it and will > > become confused upon seeing it in someone else's code, which isn't worth > it > > for something that can be easily done without a language feature. > > > > You could write a helper for it, though. > > > > > > > > On Sat, Jul 18, 2009 at 9:02 AM, ehahn <[email protected]> wrote: > > > > > Hi. Newbie alert (apologies!) > > > > > I'm really loving haml but very frequently finding starting with: > > > > > %div= foo.subject > > > > > and then not liking the empty html elements when there is no subject, > > > so I dutifully improve the output with: > > > > > - unless foo.subject.blank? > > > %div= foo.subject > > > > > I'm wondering if there is a shorthand for this (common?) usage in > > > haml? I guess what I'd love to see is something like: > > > > > %div=? foo.subject (and %div!=? etc.) > > > > > which would mean "only emit the html if the expression evaluates to a > > > non-blank value" > > > > > Is there some fantastic way to achieve this with released haml? > > > -- Regards, Gabriel Sobrinho E-mail: [email protected] Phone: +55 31 8775 8378 Don't print this e-mail. The nature is thankful and your money also. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
