Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HandlebarsTemplates object not defined without backing model #164

Closed
jwlms opened this issue Jul 9, 2018 · 6 comments
Closed

HandlebarsTemplates object not defined without backing model #164

jwlms opened this issue Jul 9, 2018 · 6 comments

Comments

@jwlms
Copy link
Contributor

jwlms commented Jul 9, 2018

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:

templates/
  contacts/
    new.hbs
    edit.hbs
    show.hbs

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 under Handlebars.templates.generic_handlebars_template.

Is there a step I'm missing for this use case:

templates/
  generic_handlebars_template

Any help here would be greatly appreciated!

@AlexRiedler
Copy link
Collaborator

@jwlms what do you mean by a backing model? (unfamiliar with the use of that term)

@AlexRiedler
Copy link
Collaborator

Have you potentially set the template_namespace to something different then HandlebarsTemplates ?

@jwlms
Copy link
Contributor Author

jwlms commented Jul 9, 2018

@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.

@jwlms
Copy link
Contributor Author

jwlms commented Jul 9, 2018

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).

@jwlms
Copy link
Contributor Author

jwlms commented Jul 9, 2018

@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.

@AlexRiedler
Copy link
Collaborator

cleaning up, going to close cause referenced PR was merged, and making sure this all works with Rails 7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants