【发布时间】:2015-05-28 13:04:51
【问题描述】:
我正在寻找更清洁的解决方案,更像 Slim,在标签内写标签,这是我目前所拥有的:
td = "#{p.created_at.to_formatted_s(:long)} <small>(#{time_ago_in_words(p.created_at)} ago)</small>".html_safe
上面的代码工作正常 - 生成我想要的输出,但对我来说看起来不干净。我已经尝试将其重写为 eRuby
<td><%= p.created_at.to_formatted_s(:long) %> <small><%= time_ago_in_words(p.created_at) %> ago)</small></td>
然后使用Erb2Slim转换器将其转换为Slim
td
= p.created_at.to_formatted_s(:long)
small
= time_ago_in_words(p.created_at)
| ago)
之后它不显示small 标签及其内容,知道如何以及在 Slim 中编写上述代码的最佳方法是什么?
【问题讨论】:
标签: ruby-on-rails ruby slim-lang