leshill / handlebars_assets

Use handlebars.js templates with the Rails asset pipeline.
MIT License
649 stars 159 forks source link

Uncaught ReferenceError: Handlebars is not defined #131

Closed tquill closed 8 years ago

tquill commented 8 years ago

I'm on rails 4.2.3, and I can't seem to get handlebars_assets set up properly. Once I try to create my first template (even if it's blank), I get an Uncaught ReferenceError in the console, and this the code it's pointing to.

(function() {
  this.HandlebarsTemplates || (this.HandlebarsTemplates = {});
  this.HandlebarsTemplates["static_pages/landing"] = Handlebars.template({"compiler":[6,">= 2.0.0-       beta.1"],"main":function(depth0,helpers,partials,data) {
    return "";
},"useData":true});
  return this.HandlebarsTemplates["static_pages/landing"];
}).call(this);

I'm sure I'm making a newbie mistake, but is there any simple rails app examples that I can look at to see how handlebars_assets is supposed to be implemented?

tquill commented 8 years ago

I got it figured out... I found this sample app (https://github.com/leshill/handlebars_rails4) and it seems that the require tree directives need to be below the handlbars.runtime directive like so.

//= require handlebars.runtime
//= require_tree ./templates
//= require_tree .
mrvovanness commented 8 years ago

@tquill thanks, helps me with the same issue