Steve Arnold
Steve Arnold

Reputation: 53

HandlebarsHelper compiled templates tempateSpec.call undefined

I am having an issue with the HandlebarsHelper compiled templates on an MVC5 site. Here is the code for the BundleConfig:

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

This was working fine locally and then I pushed to a server hosting the QA environment and I was getting an assembly reference error saying the HandlebarsHelper plugin was calling Jurassic 2.1.0.0 and it wasn't found. So I added Jurassic through Nuget, since then the templates stopped working. I get this error from the browser:

Chrome: Uncaught TypeError: undefined is not a function

Firefox: TypeError: templateSpec.call is not a function

This is happening in the following section of 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;
};

I am running:

Ember 1.7.0 Ember-Data 1.0.0-beta.11 Handlebars 1.3.0 JQuery 2.1.1

MVC 5 .Net 4.5.2

I have been searching online all morning and not found any answers yet that have worked, I tried removing the Jurassic Nuget package and it did not help. Any ideas would be appreciated, let me know if there is any other info that would help diagnosing the issue.

Upvotes: 3

Views: 771

Answers (2)

Steve Arnold
Steve Arnold

Reputation: 53

The problem was I was using a version of Handlebars Helper that only supported handlebars 2.x. Found the issue in Nuget and changed it to a different version, everything works now. Thanks for the comments.

Upvotes: 0

Kingpin2k
Kingpin2k

Reputation: 47367

You're on a version of HandlbarsHelper that's not supported for that version of Ember.js.

There was a breaking change for version 1.9 which added support for handlebars version 2.0. This is supported in HandlebarsHelper v2.0+. As a breaking change it means 2.0+ can't be used with Ember.JS < v1.9 and Handlebars < v2.0.

The reason why it was probably working initially was because in debug templates are usually just injected into the page unminified.

Easy fix is to use HandlebarsHelper v1.1 (https://www.nuget.org/packages/HandlebarsHelper/1.1.0)

Upvotes: 0

Related Questions