Mustache 如何填充模板中花括号内的变量?
How does Mustache populate the variable inside the curly braces in template?
我正在调试一个大型 Backbone Marionette 应用程序,我对它还很陌生。它还使用了我今天刚听说的 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
填充的输入数据包含类似
的内容
text : {
"Update": "Update it!",
...
}
在 http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/
中检查 "Sample 6: Nested Objects"
You can use the dot notation to access object properties.
我正在调试一个大型 Backbone Marionette 应用程序,我对它还很陌生。它还使用了我今天刚听说的 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
填充的输入数据包含类似
的内容text : {
"Update": "Update it!",
...
}
在 http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/
中检查 "Sample 6: Nested Objects"You can use the dot notation to access object properties.