2

I need in Emblem.js to transmit to i18n helper concatenated string constant with variable value, How can i do it?

each item in model.items
    div
        t "dict.{{item}}"

returns error

Missing translation for key "dict.{{item}}"
AHOYAHOY
  • 1,856
  • 4
  • 24
  • 34

1 Answers1

1

If you're using Handlebars 1.3+, you can use a subexpression. First, write a string concatenation helper:

Ember.Handlebars.helper('concat', function (a, b) {
    return a + b;
});

Then use it like this (sorry, I don't know Emblem so I'm going to use the normal stache syntax):

{{t (concat 'dict.' item)}}
GJK
  • 37,023
  • 8
  • 55
  • 74