-
Notifications
You must be signed in to change notification settings - Fork 147
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use HAML Coffee Assets with Sinatra? #37
Comments
haml_coffee_assets registers itself as tilt engine, so you can simply require the gem and start using |
thx a lot |
Could you provide an example? Thanks. |
I don't see this working as expected. This returns nothing:
|
Just returned from holidays. I'll have a look this week. |
So, I finally took some time and played with the "Tilt" integration, since it was provided by a pull request and not written by myself. First I noticed that the Haml Coffee Assets headline '.. or as Tilt template' was misleading, because it's a Sprocket engine that confirms to the Tilt template interface. This means that you can use Sprockets to compile and serve the Haml Coffee Assets to the client side, but you can't use it on the server side as Tilt template. This makes totally sense, since you'd better use Ruby Haml on the server side. I released the demo application Haml Coffee Sinatra, so you can see how to set up Sprockets in Sinatra to use Haml Coffee. |
Thanks for the demo app. I was already doing something similar by reading the erb file in the vendor directory, which works without Sprockets but feels like a hack. Could there be a public method which exposes the contents of this file in a reliable way instead? |
Which file do you mean? The Haml helpers? |
I'm accessing it like this:
but I'm concerned that the file may move at some point and my implementation will break. |
I just released 1.4.0 that allows you to get the helper functions as JavaScript String: HamlCoffeeAssets.helpers or you can also get the CoffeeScript version if you need to: HamlCoffeeAssets.helpers(false) |
Awesome. Now this:
Becomes:
|
Great. And there are specs for this, so whenever I feel to change it, I'll not break your app :P |
I did realize that when I removed coffee-script from my Gemfile, haml_coffee_assets complained. This doesn't seem right to me. |
Oh, now I remember. Haml Coffee Assets has a skeleton in the closet: I wasn't able to get the haml-coffee compiler running with the coffee-script gem, so I included my own version of CoffeeScript and used only execjs as dependency. I'll have a look again to see if I can finally get it right. |
Hi,
can I use this gem with Sinatra, and if yes could anybody indicate me the easiest solution to do this?
Thx in advance
Michał
The text was updated successfully, but these errors were encountered: