ruby - 带有 slim 类的标记后的尾随空格

标签 ruby slim-lang

我正在尝试在字体超棒的图标之后的纤细模板中添加尾随空格。

模板看起来像这样:

=link_to edit_path(the_object) do
  i.icon-pencil
  | edit

我想在标记之后(或文本之前)添加空格,所以我尝试了以下组合:

=link_to edit_path(the_object) do
  i>.icon-pencil
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil>
  | edit


=link_to edit_path(the_object) do
  i<.icon-pencil
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil<
  | edit


=link_to edit_path(the_object) do
  i.icon-pencil
  < edit

还有很多...

也许我太笨了,看不懂文档。我发现唯一有效的解决方案(但它看起来 super 不优雅)是:

=link_to edit_path(the_object) do
  i.icon-pencil
  '
  | edit

最佳答案

试试这个: |编辑(两个空格)

来自文档: “如果文本在同一行开始,则左边距设置为管道的缩进 + 一个空格。任何额外的空格都将被复制。”

关于ruby - 带有 slim 类的标记后的尾随空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25342653/

相关文章:

ruby-on-rails - 在 slim Rails 中使用属性

html - 如何将 html.slim 文件转换为 html 或 html.erb?

html - 字符串内的 ruby

html - 带有 CSS 的水平滚动单行图库

javascript - OnClick 事件未绑定(bind)/触发

ruby-on-rails - 如何在 json rails 4 中连接符号

ruby - CentOS升级后"rubygem mysql error: gem is not loaded"

ruby-on-rails - 如何坚持 REST?

ruby-on-rails - 具有动态项目数的表单

ruby-on-rails - Ruby on Rails 3 中的 Rails Metal