加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 2 haml link_to在同一行

发布时间:2020-12-17 03:37:04 所属栏目:百科 来源:网络整理
导读:我有haml代码模板如下: %td= link_to “Enable”,enable_product(@product) %td= link_to ‘Disable’,disable_product(@product) 它显示如 Enable Disable 但它显示在表格的两个单元格中.我想要显示的是仅将它放入1个单元格.喜欢 Enable/Disable Product
我有haml代码模板如下:

%td= link_to “Enable”,enable_product(@product)
%td= link_to ‘Disable’,disable_product(@product)

它显示如

Enable

Disable

但它显示在表格的两个单元格中.我想要显示的是仅将它放入1个单元格.喜欢

Enable/Disable Product

显然,我仍然想要启用和禁用下的超链接.

我怎么能在哈姆尔做到这一点?

谢谢!

解决方法

由于link_to生成一个字符串,您可以将它们连接起来:

%td= link_to("Enable",enable_product(@product))+'/'+link_to('Disable',disable_product(@product))

也许你必须将结果声明为html_safe:

%td= (link_to("Enable",disable_product(@product))).html_safe

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读