简体   繁体   English

在模板中,Mustache如何填充大括号内的变量?

[英]How does Mustache populate the variable inside the curly braces in template?

I'm debugging a big Backbone Marionette application and I'm very new to it. 我正在调试大型Backbone Marionette应用程序,但对它来说是新手。 It's also using MustacheJS which I just heard today. 它还使用了我今天刚刚听到的MustacheJS。 I found the template file which has the filename UserProfile.mst 我发现模板文件的文件名为UserProfile.mst

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

I also found the .js file that pulls this template file. 我还找到了提取此模板文件的.js文件。 It's actually RequireJS that's pulling it. 实际上是RequireJS在拉动它。

define([
  'UserProfile.mst'
],
function(UserViewTemplate) {

var obj = {
  "userItem" : {
    "template": UserViewTemplate
  }
};

return obj;
});

However, what I can't figure out is where to find text.Update 但是,我不知道要在哪里找到文本。

Input data that gets populated contains something like 填充的输入数据包含类似

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

Check "Sample 6: Nested Objects" in http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/ http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/中检查“示例6:嵌套对象”

You can use the dot notation to access object properties. 您可以使用点表示法来访问对象属性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM