leshill / handlebars_assets

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

0.18 Uncaught Error: Unknown template object: function #110

Closed attenzione closed 9 years ago

attenzione commented 9 years ago

Somewhere here:

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);
  }
  ...
PikachuEXE commented 9 years ago

I got the same error too

dbkbali commented 9 years ago

Getting similar error if updating from 17.1

AlexRiedler commented 9 years ago

Thanks for the headsup guys, updated to handlebars 0.18 without having a rails installation handy and on the go. I will try to look into it in about 3 hours from now.

AlexRiedler commented 9 years ago

@dbkbali @PikachuEXE @attenzione is this due to rails caching ? I can not longer replicate after cleaning my rails tmp folder. (Handlebars output from compile is different format; and its not backwards compatible).

attenzione commented 9 years ago

I will test it later, thanks for advise

Sent from Nexus 5 On Sep 12, 2014 11:00 PM, "Alex Riedler" notifications@github.com wrote:

@dbkbali https://github.com/dbkbali @PikachuEXE https://github.com/PikachuEXE @attenzione https://github.com/attenzione is this due to rails caching ? I can not longer replicate after cleaning my rails tmp folder. (Handlebars output from compile is different format; and its not backwards compatible).

— Reply to this email directly or view it on GitHub https://github.com/leshill/handlebars_assets/issues/110#issuecomment-55453363 .

PikachuEXE commented 9 years ago

Clearing the cache in development and recompiling the assets on deploy does solve it

attenzione commented 9 years ago

ok guys, clearing assets cache will resolve this problem, but i would recommend to add post comment when installing new gem version this issue could be closed, but can be opened some time for other users

AlexRiedler commented 9 years ago

I am gonna think about it before closing; maybe there is some way I can notify that on a gem version change it should bump the cache version or something similar (cause this is an annoying issue for developing the plugin I have as well).

attenzione commented 9 years ago

@AlexRiedler, you can add post message to gemspec, for example "after updating gem you should run rake assets:clobber to recompile all javascript" https://github.com/jnunemaker/httparty/blob/e38baab559bb078ee421676b752d9877e5828b48/httparty.gemspec#L18

tjgrathwell commented 9 years ago

Just asking the user to run rake assets:clobber isn't sufficient on Heroku, which seems to cache the old assets as well. It would be nice if there was a way for the gem to break the template cache somehow.

ghost commented 9 years ago

Uncaught Error: Unknown template object: function It doesn't go away after removing-precompiling assets, removing tmp and rake:assets:clobber

AlexRiedler commented 9 years ago

Does anyone know any better options? I will investigate some more when I have time.

simeonwillbanks commented 9 years ago

@tjgrathwell How'd you successfully deploy to Heroku? Thanks!

simeonwillbanks commented 9 years ago

https://github.com/heroku/heroku-buildpack-ruby/issues/123#issuecomment-59845522 helped.

  1. Ensure running latest sprockets-rails
  2. $ heroku plugins:install https://github.com/heroku/heroku-repo.git
  3. $ heroku repo:purge_cache -a appname
  4. $ git push heroku master
Breefield commented 9 years ago

Still seeing this error on 0.18, clearing tmp didn't work.

Breefield commented 9 years ago

Nvm, clear tmp + touch restart.txt and there we go.

deivinsontejeda commented 9 years ago

I had the same issue with ember-rails once I deleted cache, everything works as expected. So I suggest you remove the cache on rm -rf tmp/*

AlexRiedler commented 9 years ago

okay so I found a way to fix this, and will be implemented in next release! (automatically cleans cache on update of the gem).

Breefield commented 9 years ago

Wonderful, thanks Alex!

On Mon, Jan 5, 2015 at 8:52 AM, Alex Riedler notifications@github.com wrote:

okay so I found a way to fix this, and will be implemented in next release! (automatically cleans cache on update of the gem).

— Reply to this email directly or view it on GitHub https://github.com/leshill/handlebars_assets/issues/110#issuecomment-68736870 .

ccmcbeck commented 9 years ago

Thanks, Alex! This is great news.