valk
valk

Reputation: 9874

Rendering .haml from .html.erb

I'm trying to render my HAML partial (_my_partial.haml) from my html.erb file:

<%= render "shared/my_partial" %>

And getting:

ActionView::Template::Error (Missing partial shared/my_partial with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :coffee]}. Searched in:

I've noticed that :handlers doesn't contain haml.

In Gemfile I have

group :assets do
  gem 'haml-rails'
  ..
end

One thing to note: this only happens on production environment, e.g. when I'm using

RAILS_ENV production rails s

How can I add it there so it might try and find the partial later?

Upvotes: 0

Views: 2367

Answers (2)

valk
valk

Reputation: 9874

It comes out that rendering HAML from ERB can be difficult :) Luckily, render function has :handlers parameter. So the following will solve the mentioned problem:

<%= render "shared/my_partial", :handlers => [:haml] %> 

Upvotes: 2

Maksim Gladkov
Maksim Gladkov

Reputation: 3079

Move gem 'haml-rails' out of group :assets. It should do the trick.

Upvotes: 2

Related Questions