SlexAxton / require-handlebars-plugin

A plugin for handlebars in require.js (both in dev and build)
804 stars 202 forks source link

Possible requirejs.config({ enforceDefine: true}) issue with > hbs 0.10.0 #225

Open ttocco opened 9 years ago

ttocco commented 9 years ago

While attempting to upgrade from version 0.4.0 to 0.11.2 I noticed that all of my hbs templates are suddenly throwing the following errors in the console:

Uncaught Error: No define call for views/GlobalNavigationTemplate http://requirejs.org/docs/errors.html#nodefine

Backing down the version to 0.10.0 removes the errors. I suspect that this has something to do with the requirejs config option enforceDefine = true because setting this to false also removes the errors in version 0.11.2.

ttocco commented 9 years ago

I haven't reverse engineered why this fix works for the above problem but if you take hbs.js line 571 from #0.10.0 :

var tmplName = config.isBuild ? '' : "'" + name + "',";

and overwrite hbs.js line 579 from #0.11.2 :

var tmplName = "'hbs!" + name + "',";

The template name problem appears to go away if you need to use requirejs.config({enforceDefine: true}) with requirejs.