【问题标题】:HandlebarsHelper compiled templates tempateSpec.call undefinedHandlebarsHelper 编译模板 tempateSpec.call undefined
【发布时间】:2014-11-07 19:08:45
【问题描述】:

我在 MVC5 站点上遇到了 HandlebarsHelper 编译模板的问题。这是 BundleConfig 的代码:

bundles.Add(new Bundle("~/bundles/templates", new HandlebarsTransformer())
            .IncludeDirectory("~/App/templates", "*.hbs", true));

这在本地运行良好,然后我推送到托管 QA 环境的服务器,我收到一个程序集引用错误,说 HandlebarsHelper 插件正在调用侏罗纪 2.1.0.0,但没有找到。所以我通过 Nuget 添加了侏罗纪,从那时起模板停止工作。我从浏览器收到此错误:

铬: Uncaught TypeError: undefined is not a function

火狐: TypeError: templateSpec.call 不是函数

这发生在 handlebars.js 的以下部分:

return function(context, options) {
  options = options || {};
  var namespace = options.partial ? options : env,
      helpers,
      partials;

  if (!options.partial) {
    helpers = options.helpers;
    partials = options.partials;
  }
  var result = templateSpec.call(
        container,
        namespace, context,
        helpers,
        partials,
        options.data);

  if (!options.partial) {
    env.VM.checkRevision(container.compilerInfo);
  }

  return result;
};

我正在跑步:

余烬 1.7.0 Ember-Data 1.0.0-beta.11 车把 1.3.0 jQuery 2.1.1

MVC 5 .Net 4.5.2

我整个早上都在网上搜索,但没有找到任何有效的答案,我尝试删除 Jurassic Nuget 包,但没有帮助。任何想法都将不胜感激,如果有任何其他信息有助于诊断问题,请告诉我。

【问题讨论】:

  • 您使用的是哪个版本的车把助手?
  • 你能说明你是如何将它注入你的页面的吗?
  • 而且是 BundleTable.EnableOptimizations = true;
  • 我刚刚注意到nuget包中有一个错误,这意味着您使用的是v2.0。您应该使用 nuget 包的 v1.1。

标签: ember.js handlebars.js handlebarshelper


【解决方案1】:

您使用的是不受该版本 Ember.js 支持的 HandlbarsHelper 版本。

1.9 版有一个重大更改,增加了对 2.0 版车把的支持。 HandlebarsHelper v2.0+ 支持此功能。作为一项重大更改,这意味着 2.0+ 不能与 Ember.JS

它最初可能工作的原因是因为在调试模板通常只是注入到未缩小的页面中。

简单的解决方法是使用 HandlebarsHelper v1.1 (https://www.nuget.org/packages/HandlebarsHelper/1.1.0)

【讨论】:

    【解决方案2】:

    问题是我使用的 Handlebars Helper 版本仅支持 Handlebars 2.x。在 Nuget 中发现问题并将其更改为其他版本,现在一切正常。感谢 cmets。

    【讨论】:

      猜你喜欢
      • 2013-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-09-19
      相关资源
      最近更新 更多