Thanks guys, you're right. Too much hash should be avoided!

Nathan, I like both methods you've suggested - perhaps the second one
allows more flexibility.

Cheers,
Zubin

On Mar 5, 5:38 am, Nathan Weizenbaum <[EMAIL PROTECTED]> wrote:
> The canonical way to deal with large bunches of code is to move them
> into well-named helpers. This keeps logic out of your views, where it
> doesn't belong, and makes them more readable. For delete links, you
> could either do
>
>   def delete_link(page)
>     link_to "delete", page_path(page), :class => "button", :method =>
> :delete, :confirm => "Are you sure?"
>   end
>
> and then in Haml have
>
>   = delete_link page
>
> or you could do
>
>   def delete_attrs(page)
>     {:href => page_path(page), :class => "button", :method => :delete,
> :confirm => "Are you sure?"}
>   end
>
> and in Haml have
>
>   %a{delete_attrs(page)}
>
> Either way is fine. I tend to prefer calling helpers, personally, but I
> wouldn't consider dynamically creating attributes bad at all.
>
> - Nathan
>
> zubin wrote:
> > Hi folks,
>
> > I'm a recent Haml convert, and am loving it so far!
> > Am just stuck on a couple of details, if anyone can help:
>
> > What is the "best" way to write a delete link?
>
> > This works:
>
> > = link_to "delete", page_path(page)), :class => "button", :method
> > => :delete, :confirm => "Are you sure?"
>
> > This doesn't, but I'd prefer to do it like this if possible:
>
> > %a.button{ :href => page_path(page), :method => :delete, :confirm =>
> > "Are you sure?" } delete
>
> > One more thing: it seems Haml doesn't like attribute hashes to span
> > multiple lines. This is okay in most cases but some lines can get a
> > bit long. Is there a way to do this?
>
> > Thanks,
> > Zubin
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to