Topic: Can this uglyness be cleaned up?

I just bought a nice theme and while I like it, in order to get the effects/looks, some links are like:

<a href="<%= new_company_event_path(@company) %>" class="btn ui-state-default ui-corner-all">
  <span class="ui-icon ui-icon-grip-dotted-horizontal"></span>
  Add New Event...
</a>
<div class="clearfix"></div>

Maybe some type of form helper?

Thanks for any suggestions.

Re: Can this uglyness be cleaned up?

def fancy_link(text, path)
  link = link_to path, :class => "btn ui-state-default ui-corner-all" do 
    "<span class="ui-icon ui-icon-grip-dotted-horizontal"></span>#{text}"
  end
  link << "<div class="clearfix"></div>"
end

#Usage
<%= fancy_link "Add New Event...", new_company_event_path(@company) %>

Re: Can this uglyness be cleaned up?

UPDATE 2:
PROBLEM SOLVED!  DUH!!

I had a < % =  instead of < % 

lol


UPDATE:

I've modified the example as follows:

  def new_edit_link_button(text, path)
    link_to path, :class => "btn ui-state-default ui-corner-all" do 
      %'<span class="ui-icon ui-icon-document"></span>#{text}'
    end
  end

It works great but it is repeating.  If I use this twice in a view I get four buttons.

I've put it in the application helper and other helpers.  Doesn't matter.  It just keeps repeating.

When I put the link_to block directly in a view, it works as expected (no repeating).

Any suggestions?

Thanks

Last edited by cbmeeks (2009-11-26 11:01:00)