leshill / handlebars_assets

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

Support ember and backbone simultaneously #74

Closed rbhitchcock closed 11 years ago

rbhitchcock commented 11 years ago

This changeset fixes #58.

I tried to base changes on comments already in the issue. If the config option is true for multiple frameworks and ember, the code now checks for a .ember extension on files in order to compile them for ember; otherwise, it compiles them to the default JavaScript. I pulled most of the compile code into a function so that the additional logic checks still looked clean. Hopefully the config option name is sensible. I couldn't think of anything better. I also ensured that files like file.ember.hamlbars will still be compiled in this scenario as well.

I added a test and all existing tests are still passing.

leshill commented 11 years ago

Hi @rbhitchcock,

Merged.

Thanks!

Darep commented 11 years ago

:heart: Thank you @rbhitchcock! I wanted something like this just yesterday morning, and here it is.

PS. I was actually planning to implement this myself, too, but you beat me to it :) I was planning to use a Config.ember_paths list, but .ember extension works just fine, too. Again, thank you very much!

Darep commented 11 years ago

Hmm. Unfortunately, it seemed to work ok when I tested it quickly, but now that I'm actually using it in our Rails project, it doesn't actually work.

I'm not using haml or slim, so the files had to have a .hbs.ember extension to get this to work, but the URLs to templates created by Rails in dev environment had a .ember.js extension. So Rails returned a 404, because it generated a funky path.

I think @rbhitchcock meant this to work with a simple some-template.ember, but .ember is not registered for the engine, so HandlebarsAssets doesn't pick it up.

I've made a quick fix and will create a pull request shortly :hamster:

Edit: Said pull request: #78