i have this simple erb code that works perfectly, joint to my i18n.yml file. The idea is to get the client's edit.html.erb page, get the title of that page in my en.yml file and pass that title the @client.fullname variable. Like so:

<h1><%= t('client.edit.title'), :current_client => @client.fullname %></h1>

Now, i'm in the process of translating my erb files into slim. So the result of that line of code is

h1 = t('client.edit.title'), :current_client => @client.fullname

But it wouldnt pass the variable to the en.yml file. Instead, it throws this error:

/app/views/clients/edit.html.slim:1: syntax error, unexpected ',', expecting ')' ...tty2 = (t('client.edit.title'), :current_client => @client.f... ... ^

Would anyone know what i'm doing wrong here?

有帮助吗?

解决方案

The hash parameter options should be passed within the method call parentheses, like so

h1 = t('client.edit.title', :current_client => @client.fullname)

Not sure why this would have worked in ERB, but it doesn't look correct as written.

You can also remove the parentheses altogether

h1 = t 'client.edit.title', :current_client => @client.fullname

其他提示

Please try:

h1
  = t('client.edit.title'), :current_client => @client.fullname
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top