agoragames / stache

mustache and handlebars template handling in Rails 3.x and Rails 4.x
https://rubygems.org/gems/stache
MIT License
166 stars 49 forks source link

rescue from NameError/LoadError #19

Closed oliverhuang closed 12 years ago

oliverhuang commented 12 years ago

in stache / lib / stache / mustache / handler.rb line 59

The code said that "only rescue NameError/LoadError".

However, I got a 'uninitialized constant Books::Book' error.

book is my model and I have a template called app/templates/books/_book.html.mustache. And I did't define a Books::Book class in app/view/books. The error disappears only when I add a empty definition for Books::Book in app/view/books.

I think when the definition of Books::Book is missing, it should use Stache::Mustache::View instead of raising an exception. Am I right?

I use stache-0.9.1

hypomodern commented 12 years ago

Definitely. I'll take a look at it.

-mhw

On Monday, July 16, 2012 at 9:24 PM, 黄冬虹 wrote:

in stache / lib / stache / mustache / handler.rb line 59

The code said that "only rescue NameError/LoadError".

However, I got a 'uninitialized constant Books::Book' error.

book is my model and I have a template called app/templates/books/_book.html.mustache. And I did't define a Books::Book class in app/view/books. The error disappears only when I add a empty definition for Books::Book in app/view/books.

I think when the definition of Books::Book is missing, it should use Stache::Mustache::View instead of raising an exception. Am I right?

I use stache-0.9.1


Reply to this email directly or view it on GitHub: https://github.com/agoragames/stache/issues/19

oliverhuang commented 12 years ago

sorry I made a mistake. When rendering a mustache partial in ERB, I shoud use

<%= render 'books/book', book.attributes.symbolize_keys %>

instead of

<%= render '/books/book', book.attributes.symbolize_keys %>