text_field_tag 占位符忽略 rails 中 space 之后的动态文本

text_field_tag placeholder ignoring dynamic text after space in rails

我正在使用 I18n 进行国际化。使用以下代码在 text_field_tag 即时消息的占位符中以区域设置语言显示占位符内容。

<%= text_field_tag('email', "", class: 'form-control', placeholder: t('shared.enter_email')%>

config/locales/en.yml内容如下:

en:
  shared:
    enter_email: Enter Email

在运行应用程序中,占位符中的内容仅包含Enter并忽略name,因为中间有一个space。

我尝试了不同的语法,都产生了相同的结果。有办法完成吗?

我能够通过使用这样的插值来解决这个问题。

<%= text_field_tag('email', "", class: 'form-control', placeholder: "#{t('shared.enter_email')}" %>