How to Call Haml Outside Sinatra or Rails?
People would think why would you want to do that. Well, in my case I just want to use haml to generate html for me in Test so that I could inject that in to Pusher to test the functionality of the feed page. I could use static html string, but if I change haml I don’t want to come back to the test and change the string again.
So, Haml actually is just a static class that you can call anywhere, but where you call inside Sinatra or Rails controller. You could just use
However, if you do this outside Sinatra, you would get an exception that haml is not found or something close.
So here’s just a simple solution plus I’ve added how to call helper in that as well.
1 2 3 4 5 6 7 8 9 10
That’s it nice and easy!