Concatenation string with variable in emblem.js

被刻印的时光 ゝ 提交于 2019-12-20 02:56:13

问题


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:


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


来源:https://stackoverflow.com/questions/29346824/concatenation-string-with-variable-in-emblem-js

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!