Concatenation string with variable in emblem.js

2019-02-26 04:44发布

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}}"

1条回答
Deceive 欺骗
2楼-- · 2019-02-26 05:26

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)}}
查看更多
登录 后发表回答