Nested content_tag link, span, image

hi,

i’m trying to render this html:

clear cart ! arrow

the best i can do is:

<%= link_to content_tag(:span, image_tag(“img/clear.png”, :alt =>
‘arrow’)), clear_cart_path, :class => “big_button”, :title => “clear”
-%>

any ideas???

cheers.

bump.

anyone?

:frowning:

Michael D. wrote:

hi,

i’m trying to render this html:

clear cart ! arrow

the best i can do is:

<%= link_to content_tag(:span, image_tag(“img/clear.png”, :alt =>
‘arrow’)), clear_cart_path, :class => “big_button”, :title => “clear”
-%>

any ideas???

cheers.

First, I’d move the content_tag code into a helper.

def clear_cart_button
content_tag(:span, ‘clear cart !’ + image_tag(“img/clear.png”, :alt
=> ‘arrow’))
end

Then in your view…

<%= link_to clear_cart_button, clear_cart_path, :class => “big_button”,
:title => “clear” %>

Assuming you’ve added the clear_cart named route, that should work.

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