Syl*_*Syl 2 ruby-on-rails hyperlink link-to
我想要一个包含文字和图像的链接.在rails 3之前互联网告诉我你必须这样做:
<%= link_to "my text"+image_tag("image.jpg"), {:controller=>:billets}, :class => 'link_to_blog'%>
Run Code Online (Sandbox Code Playgroud)
但是在rails 3中,我在我的网页中显示了图像的代码而不是图像.现在看来,它逃脱了html代码.
如何在rails 3中使用text和image进行link_to?
fl0*_*00r 12
<%= link_to ("my text"+image_tag("image.jpg")).html_safe, {:controller=>:billets}, :class => 'link_to_blog'%>
Run Code Online (Sandbox Code Playgroud)
要么
<%= link_to {:controller => :billets}, :class => 'link_to_blog' do %>
My text
<%= image_tag "image.jpg" %>
<% end %>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1827 次 |
| 最近记录: |