【问题标题】:How to apply a link to a multiline text string in HAML?如何将链接应用到 HAML 中的多行文本字符串?
【发布时间】:2011-12-13 21:47:59
【问题描述】:

我有一个这样的多行块:

%li
  =link_to image_tag("image.jpg", :size => "48x48", :alt => "Something", :title => "Something", :class => "some-class"), some_path
  %p.testi
    "Some text right here that is divided up onto multiple lines & 
    %br
    and just won't stop running on!”

我需要一个链接来包围图像和文本。目前图像链接工作正常,但是在文本链接上,我相信我必须从 link_to 块开始,但我没有看到我应该在那里遵循的语法。

这是如何正确完成的,以便所有多行文本也都应用了链接?

【问题讨论】:

    标签: ruby-on-rails ruby ruby-on-rails-3 haml


    【解决方案1】:

    苗条(应该是相似的):

    = link_to some_path, class: "some-class" do
        h2 = "#{some_object.title}"
        p.testi
          "Some text right here that is divided up onto multiple lines & 
        br/
        and just won't stop running on!”
    

    【讨论】:

      【解决方案2】:

      Multiline string in HAML

      您想使用 |在你要换行的每一行的末尾。

      【讨论】:

        猜你喜欢
        • 2016-04-25
        • 2011-08-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2010-09-16
        相关资源
        最近更新 更多