如何将来自link_to的文本和红宝石代码放在haml的同一行上?

问题描述

| 我正在尝试通过执行以下操作在
(
)
之间放置
link_to
= div_for review do
    = link_to review.title,review_path(review)
    (
    = link_to review.user.email,user_path(review.user)
    )
结果不是我想要的,因为它在括号和链接文本之间放置了空格,因此看起来像:
 link1 ( link2 )
但我希望它看起来像:
 link1 (link2)
我该如何使用haml?     

解决方法

使用内联红宝石的字符串:
= link_to review.title,review_path(review)
=raw \"(#{link_to review.user.email,user_path(review.user)})\"
原始数据仅适用于Rails 3(及更高版本)。     ,我最近发现有关haml的有趣的东西 ==-Ruby插值字符串
%h1== (#{link-to review.user.email,user_path(review.user)})
就好像
%h1= raw \"(#{link_to review.user.email,user_path(review.user)})\"
    ,
= link_to review.title,review_path(review)
= surround \'(\',\')\' do
  = link_to review.user.email,user_path(review.user)
或者,您可以将链接放在
span
标记中,并告诉Haml吃掉空白:
(
%span>= link_to review.user.email,user_path(review.user)
)
    

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...