ruby-on-rails - 添加 rails link_to、mail_to 后,haml 删除点之前的空格

标签 ruby-on-rails haml

我正在用haml写文本:

Blab bla for any questions contact us on me@foo.com.

所以哈姆看起来像
%p
  Blab bla for any questions contact us on
  = mail_to 'me@foo.com'
  .   

笔记 。是 ascii 中的点,我也可以用 = '.' 替换该行(渲染字符串点)

但呈现的文本看起来像
Blab bla for any questions contact us on me@foo.com .

区别在于末尾点之前的空格

我想出并有效的解决方案是
%p
  Blab bla for any questions contact us on
  = mail_to('me@foo.com') + '.'

这只是我在寻找最佳实践:) thx

最佳答案

我会用这个:

%p
  Blab bla for any questions contact us on #{mail_to('me@foo.com')}.

另见 the Haml FAQ :

Expressing the structure of a document and expressing inline formatting are two very different problems. Haml is mostly designed for structure, so the best way to deal with formatting is to leave it to other languages that are designed for it.



在这种情况下,您不需要其他语言,只需插入函数即可。

关于ruby-on-rails - 添加 rails link_to、mail_to 后,haml 删除点之前的空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9499197/

相关文章:

ruby-on-rails - 如何停止渲染页面/部分

ruby-on-rails - 当我需要 UTF-8 时,Rails 应用程序一直以 ASCII-8BIT 生成 View ?

ruby-on-rails - 需要一个用于 rails 的 HTTP gem

ruby-on-rails - 在 DreamHost 上带有 rails 3 应用程序的 internal_error.html

ruby-on-rails - 使用事件模型序列化程序为充当可标记标签的标签加载 JSON 时出错

每个循环数组元素的 HAML 索引

javascript - 将 javascript 变量传递给 javascript HAML 中的 ruby​​ 函数调用

mysql - 无法在 64 位 Win7 上安装 fedena

javascript - 将 Javascript 添加到应用程序布局 View 页面

css - haml & scss - 一行上有两种样式