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

Templates not found when template_is_class=true and Stache.template_base_path is relative #52

Open
rwd opened this issue Apr 16, 2015 · 0 comments

Comments

@rwd
Copy link
Contributor

rwd commented Apr 16, 2015

When we have:

  • a gem containing Mustache templates and a Rails engine
  • that gem's Rails engine setting Stache.template_base_path to a relative path, e.g. "app/templates"
  • a Rails application including that gem in its bundle

... then in general, everything works: Mustache templates are loaded from the application's app/templates directory if they exist, or if not, then from the gem's. View classes are created in the application's app/views directories.

The problem is when Stache::Mustache::Handler#compile identifies the template as a class, in our case a false positive because the source includes the string "module". It then looks for a template file in the Stache.template_base_path as though it was an absolute path and:

  1. finds nothing because Stache.template_base_path is relative
  2. does not detect that no file is found and attempts to read it anyway
  3. File.read(file) (L64) fails with a TypeError, with the message "no implicit conversion of nil into String"
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

1 participant