【问题标题】:Concatenation string with variable in emblem.js连接字符串与会徽.js中的变量
【发布时间】:2015-03-31 01:12:55
【问题描述】:

我需要在 Emblem.js 中将带有变量值的连接字符串常量传输到 i18n 助手,我该怎么做?

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

返回错误

Missing translation for key "dict.{{item}}"

【问题讨论】:

    标签: ember.js handlebars.js emblem.js


    【解决方案1】:

    如果您使用的是 Handlebars 1.3+,则可以使用 subexpression。首先,编写一个字符串连接助手:

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

    然后像这样使用它(抱歉,我不知道 Emblem 所以我将使用普通的 stache 语法):

    {{t (concat 'dict.' item)}}
    

    【讨论】:

    • 谢谢 t (concat-text "dict." item) 在会徽.js
    猜你喜欢
    • 2016-07-23
    • 2018-01-02
    • 2014-07-20
    • 1970-01-01
    • 2012-06-24
    • 1970-01-01
    • 1970-01-01
    • 2015-05-05
    • 1970-01-01
    相关资源
    最近更新 更多