使用link_to方法渲染复杂的标记

时间:2013-11-17 06:05:25

标签: ruby-on-rails

<a class="lightbox-trigger" data-lightbox="gallery" href="large.jpg"
title="A large image" coords="Right here">
    <%= image_tag("large.jpg", alt: "pass", width: "220", height: "147")%>
        <p> Jackie Smith
        <br />
        Won 5 October 2013
        </p>
</a>

是的,我有这个糟糕的html和erb(确实有用!),但是我想要正确地做事并用link_to方法渲染整个事情。但我不知道该怎么做,我现在只能使用link_to渲染文本。

1 个答案:

答案 0 :(得分:1)

<% link_to "large.jpg", class: 'lightbox-trigger', data: {lightbox: :gallery}, title: 'A large image', coords: 'Right here' do %>
    <%= image_tag("large.jpg", alt: "pass", width: "220", height: "147")%>
        <p> Jackie Smith
        <br />
        Won 5 October 2013
        </p>
<% end %>