e7h4n / handlebarsify

handlebarsify
4 stars 0 forks source link

Requiring a simple HBS causes an exception #1

Open brugnara opened 10 years ago

brugnara commented 10 years ago

Here's my HBS:

<!--
  Loading spinner (when checking user status)
-->
<div class="loading">
  <i class="fa fa-spinner fa-spin checks-spinner"></i>
</div>

Here's how I am requiring it:

var template = {
  'spinner-template': require('./views/spinner-template.hbs'),
  'login-form-template': require('./views/login-form-template.hbs'),
  'logout-form-template': require('./views/logout-form-template.hbs')
};

Here's where the error occurs (notice the *\ HERE ):

exports.checkRevision = checkRevision;// TODO: Remove this line and break up compilePartial

function template(templateSpec, env) {
  /* istanbul ignore next */
  if (!env) {
    throw new Exception("No environment passed to template");
  }
  if (!templateSpec || !templateSpec.main) {
    throw new Exception('Unknown template object: ' + typeof templateSpec); // *** HERE
  }

  // Note: Using env.VM references rather than local var references throughout this section to allow
  // for external users to override these as psuedo-supported APIs.
  env.VM.checkRevision(templateSpec.compiler);

The throw is legit, because the compiled template doesn't have the .main, here's the templateSpec value:

function (Handlebars,depth0,helpers,partials,data) {
  this.compilerInfo = [4,'>= 1.0.0'];
helpers = this.merge(helpers, Handlebars.helpers); data = data || {};

  return "<!--\n  Loading spinner (when checking user status)\n-->\n<div class=\"loading\">\n  <i class=\"fa fa-spinner fa-spin checks-spinner\"></i>\n</div>";
  }

Any idea on this? Many thanks and thanks again for this module.

brugnara commented 10 years ago

Notice that this is not happening with handlebars vs 1.2 but 2.0

rally25rs commented 9 years ago

Same error for me. This library does not seem to be updated for Handlebars 3 either. The hbsfy project does work with Handlebars 2 and 3.