I am a big believer in not starting out full throttle with things like ember-rails or other crazy asset-pipeline helpers when you have absolutely no clue what you are doing.
So naturally when I did my first serious Ember.js application I just went with the basic Ember starter kit and dumped all my templates into script tags in the html.
After doing so I can say with confidence I managed to hit every single stumbling block along the way so I decided to write down where I went wrong.
Hopefully this helps some other poor soul before he has to dive deep into the bowels of Ember like I had to :).
First step was to move the content of my script tags into a
/templates folder inside my
Don't forget to require the directory from your
application.js manifest file.
Once done the Handlebars compilation part seemed to work perfectly.
Only problem: Ember.js doesn't actually care for the contents of
HandlebarsTemplates and will just silenlty ignore them.
Instead Ember.js wants it's templates to be registered on
Ember.TEMPLATES and even more annoying: It won't complain if a template is not registered correctly unless you turned the right arcane debug setting on (yay!)
To actually get Ember to tell you if your templates can't be found you have to turn on debugging through the
LOG_VIEW_LOOKUPS: true //the important part!
Now on to get the
First I RTFM and HandlebarsAssets has Ember.js support built in, so to enable it you simply create a
config/initializers/handlebars.rb file and put the following in:
HandlebarsAssets::Config.ember = true
And if you did compile your templates before you'll see absolutely no change.
Yes that's right, nothing will happen because HandlebarsAssets caches the template output in
/tmp. So to actually see your Ember templates show up you'll have to do a
rm -rf tmp/.
Hope this helps - I'm now off raising tickets and maybe fixing some of these stupidities.. There is just no real reason for this to be such a piss-poor experience.