简体   繁体   中英

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. It's also using MustacheJS which I just heard today. I found the template file which has the filename 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. It's actually RequireJS that's pulling it.

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/

You can use the dot notation to access object properties.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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