Haml:如何删除文本周围的空格

Haml: How to remove whitespace around text

我想删除名称后的 space 并使用 HAML 完成最终 HTML 的效果: 约翰,首席执行官

%p.about_title_bx
  = truncate about.name,length:100
  , #{truncate about.position,length:100}

您可以添加 < 以删除空格:

%p.about_title_bx<
  = truncate about.name,length:100
  , #{truncate about.position,length:100}

Whitespace Removal: > and <

此外,请记住 HAML 应该有助于结构,而不是内容。使用辅助方法或内联内容可能是更好的解决方案。