Remco
Remco

Reputation: 683

Concatenated i18n string with variable in HAML

This is my code

%ul.thumbnails
  %li.span3
    %header
      %h2
        = link_to t('homepage.house.link'), houses_path

I have a variable @country.name. How can I add/concatenate this variable to t('homepage.house.link')?

Upvotes: 2

Views: 2209

Answers (1)

AdamT
AdamT

Reputation: 6485

I'm not sure how t() works. What about:

= link_to t("homepage.house.link" + @country.name), houses_path

If you just want the link name change you can do:

= link_to t("homepage.house.link") + @country.name, houses_path

Or string interpolate the entire line:

= link_to "#{t('homepage.house.link')} #{@country.name}", houses_path

Upvotes: 3

Related Questions