Reputation: 48555
Rails has the link_to
helper, and I'm aware that its output is determined by the ActionView::Helper::UrlHelper` method, but what is an easy and simple way to modify the behavior or rather make a different helper that would work similarly, the default behavior would output something similar to:
<a href="/blah" class="my_link">go to blah</a>
So say I wanted to have a <span>
inside the <a>
like so:
<a href="/blah" class="my_link"><span>go to blah</span></a>
If I wanted to create the helper, I'm aware that I should probably put in in my app/helpers/application_helper.rb
file but how would I construct it?
Upvotes: 0
Views: 369
Reputation: 7725
Helper is just normal function, there is nothing magic about it:
def my_link_to
put your code here
end
Upvotes: 0
Reputation: 5869
link_to takes a block. You can do just about anything you want in there.
Upvotes: 2