Mustache如何在模板中的花括号内填充变量



我正在调试一个大型Backbone木偶应用程序,我对它非常陌生。它还使用了我今天刚听说的MustacheJS。我找到了文件名为UserProfile.mst的模板文件

// This is  UserProfile.mst
<div class="userProperty">
  <span>{{ text.Update }}</span>
</div>

我还找到了拉这个模板文件的.js文件。实际上是RequireJS在拉它。

define([
  'UserProfile.mst'
],
function(UserViewTemplate) {
var obj = {
  "userItem" : {
    "template": UserViewTemplate
  }
};
return obj;
});

然而,我不知道的是在哪里找到文本。更新

填充的输入数据包含如下内容

text : {
        "Update": "Update it!",
        ...
    }

检查http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/

中的"示例6:嵌套对象"

你可以使用点符号来访问对象属性。

最新更新