简体   繁体   English

重构haml以使用rails link_to helper

[英]Refactor haml to use rails link_to helper

I have the following haml markup: 我有以下haml标记:

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

Is there any way of rewriting this to use Ruby on Rails link_to helper? 有什么办法可以重写它以使用Ruby on Rails link_to helper?

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

In a single line: 在一行中:

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

You can pass a block to link_to helper: 您可以将一个块传递给link_to助手:

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

or in one line: 或一行:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM