Closed kwhitaker closed 11 years ago
Nevermind, hah. Was a naming problem. My templates were named .html.slimbars
, as opposed to just .slimbars
.
^ reasons I wish the asset and view pipelines in rails were merged together.
Is there any way to make using .html.hbs work? I am using the same template for both client and server-side rendering, and the solution I came up with requires it to be named {action}.html.hbs ..HBA compiles it just fine, but neglects to ever include the compiled file.
If I copy and paste the compiled template into the console, everything's hunky-dory.
If I can't figure out the extension piece... well, I'll have to figure out how to stop Rails from rendering my JSON response with the handlebars template :/
@wideopenspaces, What do you mean by it "neglects to ever include the compiled file" ?
I think 'require_tree' skips it, because the compiled file ends up with the name 'show.html' ... if I can figure out a way to strip all extensions instead of just the last, I imagine it would be written out to 'show.js' and be properly included.
@wideopenspaces; make handlebars register the combined extension might work as in ".html.hbs" instead of the default. If that doesn't work I can see what I can do.
Yep, I tried that one. I'll poke around a bit more to see what I can figure out.
@wideopenspaces are you on the latest version that came out this weekend? make sure to clear your rails cache when testing (I know,.... its really annoying to test).
Also what gem are you using to do "same template for both client and server-side rendering" ?
I was working on my fork of @variousauthor's fork with support for server-side rendering, attempting to make it work cleanly with render_with
... I got it working (as an aside, I lost an entire weekend to the innards of ActionView and ActionController mysteries): https://github.com/wideopenspaces/handlebars_assets/compare/adds_responder
When I came up for air, you'd released the brand new version. I was going to attempt to get things working on the old version, then pull the new version and see if I could port them over.
Oh Okay, @wideopenspaces been there done that see: https://github.com/AlexRiedler/tilt_action_view
I wandered through Sprockets. The answer was staring me in the face in the code.
If I name the template show.jst.hbs
, Sprockets saves the compiled template as show.jst
, which it is more than happy to include. I just had to adjust my code to look for formats: [:js, :jst]
instead of formats: [:html]
, and remove jst.hbs
from the list of extensions that get the custom ActionView renderer.
(The reason for the last part is this: if jst.hbs
is registered to a custom renderer in ActionView, the .jst part of the extension is not seen as a format extension)
@wideopenspaces good job, now I just need to document it ...; the only major code change in the new version fyi is a file rename (since the old name is not consistent with other ruby tilt libraries).
I'm pretty sure the one I forked from is at least a few generations back, but that won't stop me!
Trying to get this gem working in our Rails 3 app, but the global namespace for templates is coming back as 'undefined,' both in my coffee files and in my Chrome console.
My
application.js.coffee
looks like this:I've tried moving the
./templates
directory up and down the list, and nothing fixes it. Everything else functions just fine (I'm able to callBackbone.Model
, for instance).This is in my dev environment. My
development.rb
looks like this:Thanks for any help!