Link_to with span

Hi there,

I want to create a link with a ‘span’ inside such as

Home

I’m trying to do it so that it highlights the current navigation, using
something I found online I have this.

def section_link(name,options)
if options[:action] == @current_action and options[:controller] ==
@current_controller
link_to(name, options, :class => ‘on’)
else
link_to(name,options)
end
end

So I effectively want the link_to to be able to contain the span, any
ideas?

Much appreciated!

Pete

The first argument to link_to can be any text you want, so include a
span if you want:

link_to( content_tag( :span, “Hello”), options )

That being said, if you want the span to include everything inside the
tag, why not just apply the styling to the tag, as in the
example you found?

On Aug 18, 1:41 am, Pete M. [email protected]

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs