문제

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