【问题标题】:Handlebars templates: top level data disappears in #each?车把模板:顶级数据在#each 中消失?
【发布时间】:2014-01-11 20:00:31
【问题描述】:

为什么顶层对象数据在handblebars 的#each 中消失了?例如,

jquery + 车把,

$(this).html(Handlebars.getTemplate('summary')({
     base_url: "http://www.mywebsite.com/", // what I mean by the top level data
     types:  {
        page: {...},
        post: {...}
     }
}));

把手模板,

{{ base_url }} // I get http://www.mywebsite.com/

{{#each types}}

{{ base_url }} // I get nothing

{{/each}}

那么我怎样才能保留顶级数据呢?

【问题讨论】:

    标签: jquery foreach iteration handlebars.js


    【解决方案1】:

    您可以通过使用达到each 迭代之外的范围 {{../base_url}}

    抱歉,如果格式草率,我是在手机上输入的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-08-07
      • 2013-02-15
      • 1970-01-01
      • 2015-05-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多