重构haml以使用rails link_to helper

时间:2016-11-30 11:17:23

标签: html ruby-on-rails ruby haml

我有以下haml标记:

%a.logo-text{href: "/surveys"}
    %b Survey
    Builder

有没有办法重写这个来使用Ruby on Rails link_to帮助器?

2 个答案:

答案 0 :(得分:1)

= link_to '/surveys', class: 'logo-text' do
  %b Survey
  Builder

单行:

= link_to raw('<b>Survey</b>Builder'), '/surveys', class: 'logo-text'

答案 1 :(得分:1)

您可以将一个块传递给link_to helper:

= link_to "/surveys", class: "logo-text" do
  %b Survey
  Builder

或一行:

= link_to "<b>Survey</b>Builder".html_safe, "/surveys", class: "logo-text"