Closed twyfordr closed 11 years ago
Hi @twyfordr,
You should be accessing it as '_goal_steps' (see the discussion in the README https://github.com/leshill/handlebars_assets#partials).
One thing to note is that you can see the partials that have been registered with Handlebars. In the JS console, take a look at:
Handlebars.partials
That should have the partial in it.
I should have mentioned that I was using the JS console when troubleshooting - Handlebars.partials is empty. I do see my templates under the JST object. No partials.
Hi @twyfordr,
How are you including your templates on the page? Is the template being included into application.js
or another manifest file?
From the web inspector (using Chrome/Safari or Firebug in FF) you should see the template in your JS source for the page.
My partials work in versions 0.4.4, 0.6.6, and 0.6.7, but when I upgrade to 0.7.1 I get the error Uncaught Error: The partial snapshot could not be found
. Actually after git bisecting the error to that gem update, reverting back to 0.4.4, and then re-upgrading to 0.7.1, now everything works fine.
Not sure what happened to cause the error.
I spoke too soon. I now have the same problem in prod. It works fine in dev and staging now, but I get the unknown partial error Uncaught Error: The partial snapshot could not be found
in production.
Hi Peter,
Interesting, please check the results of looking at Handlebars.partials
in the web inspector on both development and production.
I had to rollback production. Result from staging, running the same code as production was:
Handlebars.partials
ReferenceError: Handlebars is not defined
This is interesting. It means that the pages I have been so far able to access on staging hadn't been using handlebars, which is why I assumed staging was working. I think it was working in dev on new handlebars, with old partial syntax, but maybe that was an artifact of something else.
I now think the issue is that I upgraded and didn't know to upgrade how partials were referenced. I am doing that now.
On dev, on a page where I know partials are used, after switching to the new syntax to render a partial at snapshots/_snapshot.hbs
like this `, I get this error:
Uncaught Error: The partial _snapshots_snapshot could not be found `
When I inspect as you suggested I get a list of partials that only has one file prefixed by _ and is missing almost all of my partials.
Hi @pboling,
Are the rest of the files regular templates? Or just misnamed partials?
@leshill It is very strange. I do have a partial that has the same name as a template. Here is the full list of my templates dir:
∴ find app/assets/templates
app/assets/templates
app/assets/templates/connectors
app/assets/templates/connectors/screen.hbs.erb
app/assets/templates/connectors/screen_none.hbs
app/assets/templates/invite
app/assets/templates/invite/_invite_using_email.hbs
app/assets/templates/invite/_invite_using_facebook.hbs
app/assets/templates/invite/invite_cell.hbs
app/assets/templates/invite/screen.hbs
app/assets/templates/legacy
app/assets/templates/legacy/_convo_bubble_rest.hbs.erb
app/assets/templates/legacy/acquaintances_screen.hbs.erb
app/assets/templates/legacy/conversations_screen.hbs.erb
app/assets/templates/legacy/convo_bubble_left.hbs.erb
app/assets/templates/legacy/convo_bubble_right.hbs.erb
app/assets/templates/matches
app/assets/templates/matches/conversation.hbs.erb
app/assets/templates/matches/match_box.hbs.erb
app/assets/templates/matches/nav_locked.hbs.erb
app/assets/templates/matches/nav_thread.hbs.erb
app/assets/templates/matches/pane_conversation.hbs.erb
app/assets/templates/matches/pane_locked.hbs.erb
app/assets/templates/matches/pane_maybes.hbs.erb
app/assets/templates/matches/pane_pending.hbs.erb
app/assets/templates/matches/pane_revealed.hbs.erb
app/assets/templates/matches/pending_box.hbs.erb
app/assets/templates/matches/screen.hbs.erb
app/assets/templates/nav
app/assets/templates/nav/nav.hbs.erb
app/assets/templates/settings
app/assets/templates/settings/_email.hbs.erb
app/assets/templates/settings/_photo.hbs
app/assets/templates/settings/_photos.hbs.erb
app/assets/templates/settings/screen.hbs
app/assets/templates/shared
app/assets/templates/shared/_avatar.hbs
app/assets/templates/shared/_avatar_large.hbs
app/assets/templates/shared/snapshot.hbs
app/assets/templates/snapshots
app/assets/templates/snapshots/_snapshot.hbs
app/assets/templates/snapshots/finished.hbs
app/assets/templates/snapshots/karma_10f.hbs.erb
app/assets/templates/snapshots/karma_10f_cell.hbs
app/assets/templates/snapshots/no_snapshots.hbs.erb
app/assets/templates/snapshots/screen.hbs
@leshill Now if I grep that for just the partials, and compare it to my list, I am left scratching my head::
∴ find app/assets/templates | grep /_
app/assets/templates/invite/_invite_using_email.hbs
app/assets/templates/invite/_invite_using_facebook.hbs
app/assets/templates/legacy/_convo_bubble_rest.hbs.erb
app/assets/templates/settings/_email.hbs.erb
app/assets/templates/settings/_photo.hbs
app/assets/templates/settings/_photos.hbs.erb
app/assets/templates/shared/_avatar.hbs
app/assets/templates/shared/_avatar_large.hbs
app/assets/templates/snapshots/_snapshot.hbs
Hi @pboling,
Have you just changed the settings/_photos.hbs
file recently? It looks like only that file was actually recompiled. All the others have names from the old partial behavior.
On your dev environment, you should run rake tmp:clear
to clear out any pre-compiled templates and then check.
@leshill rake tmp:clear
did not seem to have an effect. But, yes, I did change that partial in material ways recently. I am now changing them all by adding the following to each one:
<script>
// TODO: Delete This script tag
</script>
After changing all my partials with the tag as above, re-running rake tmp:clear
and restarting my server I am still having the exact same object returned from Handlebars.partials as before, with only the one with an _
.
Hi @pboling,
Just to be clear, running rake tmp:clear
in development will only affect development and only if you are not putting them back into the public
folder. The exact configuration escapes me at the moment, but if you have files in public/assets
you will be pulling the files from there.
Full disclosure: I am brand new to handlebars, coming into a project that makes extensive use of it with Backbone.js for the views. It uses the asset pipeline, and is on latest rails and Ruby.
And, yes I have also recently run rake assets:precompile
locally... so that is f
ing me up.
WOW. You are a bad ass @leshill. Thanks for fixing me. :)
Hi @pboling,
No worries, this has cropped up before and nailing down what is happening and what to do to get it right is useful (and going into the README
.) That said, I am being kicked out of this coffee shop.
Good luck!
I've tried several different things, but can't get my partial to be recognized by Handlebars. I'm using handlebars_assets 0.6.6 and rails 3.2.3 (although I've also tried against 3.2.8). My templates are working, just not partials. My partial is in a subdirectory named goals and is named _steps.jst.hbs. I'm trying to access it as goal_steps.
I'm getting an exception in invokePartial() of Handlebars.js that the partial can't be found. The partials array is empty.
I am using the JST namespace. I set a breakpoint in tilt_handlebars after reading another issue, and I see the call to register_partial with the correct partial name.
What else should I try?