簡體   English   中英

在模板中,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": "Update it!",
        ...
    }

http://coenraets.org/blog/2011/12/tutorial-html-templates-with-mustache-js/中檢查“示例6:嵌套對象”

您可以使用點表示法來訪問對象屬性。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM