leshill / handlebars_assets

Use handlebars.js templates with the Rails asset pipeline.
MIT License
646 stars 159 forks source link

README should specify how to add assets path outside of Rails #13

Closed bloudermilk closed 12 years ago

bloudermilk commented 12 years ago

Hey guys,

Firstly, thanks for the time you've invested in this gem. It really simplified the process of getting Handlebars in a my Sinatra app.

I had one problem, though, and that was informing my Sprockets::Environment instance of the asset path supplied by this gem. I eventually got it working after delving into the source code, but it's quite a hack:

handlebars_path = HandlebarsAssets::Handlebars.send(:assets_path).join("javascripts")
environment.append_path(handlebars_path)

How did you guys intend for the asset path to be included? Let me know and I'll be happy to update the README to include instructions and send a pull request.

leshill commented 12 years ago

Hi,

Yea, that is a problem — Rails knows how to pull things out of vendor/assets. The assets_path above is really only used to get the handlebars.js code for execjs to run the compiler.

What seems to be the accepted way to do this is to have a path available off of the top module Handlebars, @josh does that here: https://github.com/josh/ruby-modernizr .

Perhaps you could make that change and then document it.

bloudermilk commented 12 years ago

I figured that would be the solution. I'll work on this some time this week and issue a pull request with the new method and an updated README.