napazone / haml_assets

Use Haml with Rails helpers in the asset pipeline
MIT License
84 stars 22 forks source link

Partial rendering not working #16

Open apolzon opened 11 years ago

apolzon commented 11 years ago

Not sure exactly what is going on, but I've been thus far unable to get haml_assets to properly find any partials.

My hbs template is located in app/assets/javascripts/templates/quiz/xyz.hbs.haml My html partial is located under app/views/agents/_badges.html.haml

I've tried rendering a partial like so: = render "agents/_badges.html.haml"

The thrown exception told me it was only looking in the app/assets folders, so I tried moving the _badges.html.haml file into app/assets/javascripts, also tried using relative paths in the render call, always the same results.

ERROR: compiling /Users/apolzon/dev/homelight/app/assets/javascripts/templates/quiz/wide_agent_card.hbs.haml RAISED Missing partial assets/javascripts/_badges.html with {:locale=>[:en], :formats=>[:html, :text, :js, :css, :ics, :csv, :png, :jpeg, :gif, :bmp, :tiff, :mpeg, :xml, :rss, :atom, :yaml, :multipart_form, :url_encoded_form, :json, :pdf, :zip], :handlers=>[:erb, :builder, :coffee, :haml, :rabl]}. Searched in:
  * "/Users/apolzon/dev/homelight/app/assets/fonts"
  * "/Users/apolzon/dev/homelight/app/assets/images"
  * "/Users/apolzon/dev/homelight/app/assets/javascripts"
  * "/Users/apolzon/dev/homelight/app/assets/stylesheets"
leshill commented 11 years ago

Hi @apolzon,

Did you end up resolving this issue? Are you using v0.2.1?

apolzon commented 11 years ago

No, I wasn't able to resolve this. I am on v0.2.1.

I ended up side-stepping the issue by re-jiggering my payload and how I was constructing the template.

apolzon commented 11 years ago

Update:

I am able to render a template or partial in the app/assets/javascripts/templates directory (or, I believe, anything under app/assets or vendor/assets):

= render partial: "templates/test" # renders app/assets/templates/_test.html.haml OR = render template: "templates/test" # renders app/assets/templates/test.html.haml

However, I am still unable to render a file that resides in the app/views directory. If I have to duplicate all my content into a partial/template under app/assets, the feature has a much smaller use case.

Any ideas on how to add app/views to the lookup paths?

leshill commented 11 years ago

Hi @apolzon,

Yes, rendering only looks to the assets path currently. Check the latest pull request and see if you can find someone else to use it too :)