开发者

Is it possible to add HTML (such as an img tag) to link_to helper in rails3?

开发者 https://www.devze.com 2023-02-20 08:27 出处:网络
I see it being escaped, and in this case want to avoid that for a certain link. Or is the only way to build the link with HTML and ERB?

I see it being escaped, and in this case want to avoid that for a certain link. Or is the only way to build the link with HTML and ERB?

link_to("#{image_tag(@image.image.mini.url)} Next", @image.next_image, :class => "scroll next") if @image.next_image

EDIT: realising it may be my str开发者_如何学Going-building that causes the problem, added my code to illustrate.


This?

= link_to @image.next_image do
   <span> hey ya'll i'm some html! </span>


Use .html_safe.

link_to("#{image_tag(@image.image.mini.url)} Next".html_safe, @image.next_image, :class => "scroll next") if @image.next_image
0

精彩评论

暂无评论...
验证码 换一张
取 消