Closed jwlms closed 1 year ago
@jwlms what do you mean by a backing model? (unfamiliar with the use of that term)
Have you potentially set the template_namespace
to something different then HandlebarsTemplates
?
@jwlms what do you mean by a backing model? (unfamiliar with the use of that term)
I just mean a model in general. A Contact
model, would generally have a view /contacts/new.html
etc. I think you would say the contact pages have a backing Contact
model. Maybe it's not that important in my case.
Have you potentially set the template_namespace to something different then HandlebarsTemplates ?
I did attempt this at an earlier point just to see if I could get this gem working, but was unsuccessful. Currently I don't have template_namespace
set. It's possible it's something with my applications config though.. I will give this a try on a new Rails app.
I'm seeing the same behavior with a new rails app. There doesn't seem to be anything created in the HandlebarsTemplates
namespace. Is there possibly a step that I'm missing? (fwiw I'm using Rails 3).
@AlexRiedler - I put up a PR to fix the issue I've run into. This seems like it should have limited side effects, but I don't know the project well.
Alternatively, to get this to work on Rails 3 I was able to add this to my application.rb
file:
config.before_initialize do
Sprockets.register_engine '.hbs', HandlebarsAssets::HandlebarsTemplate
end
Which could be used as an alternative to the PR if it's not up to spec.
cleaning up, going to close cause referenced PR was merged, and making sure this all works with Rails 7
I've been trying (and failing) to integrate this gem into non-standard Rails 3 application (which is mostly JavaScript and lacks a typical backing model).
The example provided in the README is a Contact model:
My primary question is:
Does this gem work without a backing model? As following the steps in the README for my use case, provides me with a consistent error message of
HandlebarsTemplates is not defined
. I have templates in the templates directory and am able to manually precompile the templates and include them into the application with the runtime and access them underHandlebars.templates.generic_handlebars_template
.Is there a step I'm missing for this use case:
Any help here would be greatly appreciated!