dnagir / ruby-haml-js

HAML-JS Tile and Rails 3.1 Template
MIT License
86 stars 13 forks source link

Running Outside Rails #13

Closed pablofierro closed 11 years ago

pablofierro commented 11 years ago

Hello, awesome gem.

I read this works with or without Rails asset pipeline, I'm working on a project with Middleman which uses sprockets but I can't get the .jst.hamljs templates to be processed by the gem.

The template text shows up in the JST function but it wasn't processed as it's showing haml markup.

Any ideas why this is happening or is there something I need to do to set it up outside of Rails ?

Cheers

pablofierro commented 11 years ago

Sorry, browsing through the source code I found the Sprockets processor is only registered when using with Rails.

manufaktor commented 11 years ago

@pablofierro I'm having the same problem with middleman 3.1.4, but your solution is giving me undefined method 'register_engine' for Middleman::Sprockets:Module?

Is this still a working solution for you? Thx!

pablofierro commented 11 years ago

@manufaktor Yes, I'm still using this on the same version as you are running(3.1.4), try just copying and pasting the code above your comment. It's working like a charm for me.

dnagir commented 11 years ago

@manufaktor look at the error you are getting closer. It is saying that the Sprockets isn't available. Make sure you can require it and it is available.

manufaktor commented 11 years ago

@dnagir yeah I tried that like it's done in engine.rb by requiring sprockets and sprockets/engines, but no luck. Anyway, I guess this has nothing to do with ruby-haml-js

bluerouse commented 11 years ago

Did you solved this issues @manufaktor? I'm running exactly the same issues with middleman, when trying to use ruby-haml-js... I'd be glad for your solution!

manufaktor commented 11 years ago

nope, could not solve it, switched to ejs because I had to get stuff done. :(

bluerouse commented 11 years ago

Actually, i found now, after some more searching in the last hours the following: Put :: before the Code and integrate into the config.rb from your middleman-project like this:

::Sprockets.register_engine '.hamljs', ::RubyHamlJs::Template

Worked for me, but i'm not so happy with the haml-js notation... trying out more examples now, where the limitations are.

Hope I could help you, thanks for answering so fast!

pablofierro commented 11 years ago

@bluerouse yes, that's the solution I entered in my closing comment. '::' is to access the Sprockets namespace.