I'm thoroughly enjoying HAML and SASS in my Rails application development. I wanted to use my local haml gem processor as a pre- processor for .haml files outside of Rails as well, so I could develop all of my HTML code with this incredible markup.
The idea is that all files with the suffix .haml should be processed through haml, while the rest will retain their original processing. I tried adding the following lines to my .htaccess file (on Dreamhost) without success:
This gives me a slow response, and a "Rails application failed to start properly" error, in a directory where I have not installed any Rails code. Can anyone spot the problem? If so, I'd love to get this working!
IIRC, the Haml command line utility outputs to another file by default. Since CGI uses stdin/out, you'd have to pass some options to Haml to force it to use stdout, or write a script that acts as the handler and does that for you. Keep in mind that Ruby's CGI interface is really slow w.r.t. Apache -- a new interpreter has to be spawned every time there is a request. I would suggest implementing some sort of caching, perhaps as part of the initial request.
Sean
On 7/29/07, Mike Zillion <mikezill...@gmail.com> wrote:
> I'm thoroughly enjoying HAML and SASS in my Rails application > development. I wanted to use my local haml gem processor as a pre- > processor for .haml files outside of Rails as well, so I could develop > all of my HTML code with this incredible markup.
> The idea is that all files with the suffix .haml should be processed > through haml, while the rest will retain their original processing. I > tried adding the following lines to my .htaccess file (on Dreamhost) > without success:
> This gives me a slow response, and a "Rails application failed to > start properly" error, in a directory where I have not installed any > Rails code. Can anyone spot the problem? If so, I'd love to get this > working!
> IIRC, the Haml command line utility outputs to another file by > default. Since CGI uses stdin/out, you'd have to pass some options to > Haml to force it to use stdout, or write a script that acts as the > handler and does that for you. Keep in mind that Ruby's CGI interface > is really slow w.r.t. Apache -- a new interpreter has to be spawned > every time there is a request. I would suggest implementing some sort > of caching, perhaps as part of the initial request.
> Sean
> On 7/29/07, Mike Zillion <mikezill...@gmail.com> wrote:
> > This sounded like a fun idea, but no luck yet.
> > I'm thoroughly enjoying HAML and SASS in my Rails application > > development. I wanted to use my local haml gem processor as a pre- > > processor for .haml files outside of Rails as well, so I could develop > > all of my HTML code with this incredible markup.
> > The idea is that all files with the suffix .haml should be processed > > through haml, while the rest will retain their original processing. I > > tried adding the following lines to my .htaccess file (on Dreamhost) > > without success:
> > This gives me a slow response, and a "Rails application failed to > > start properly" error, in a directory where I have not installed any > > Rails code. Can anyone spot the problem? If so, I'd love to get this > > working!
Awesome! You might get an even better performance boost if you can move the timestamp checking into the Apache configuration, perhaps as rewrite rules. I imagine it can be done, I'm just not a mod_rewrite whiz.
> On 7/30/07, Sean Cribbs <seancri...@gmail.com> wrote:
>> IIRC, the Haml command line utility outputs to another file by >> default. Since CGI uses stdin/out, you'd have to pass some options to >> Haml to force it to use stdout, or write a script that acts as the >> handler and does that for you. Keep in mind that Ruby's CGI interface >> is really slow w.r.t. Apache -- a new interpreter has to be spawned >> every time there is a request. I would suggest implementing some sort >> of caching, perhaps as part of the initial request.
>> Sean
>> On 7/29/07, Mike Zillion <mikezill...@gmail.com> wrote:
>>> This sounded like a fun idea, but no luck yet.
>>> I'm thoroughly enjoying HAML and SASS in my Rails application >>> development. I wanted to use my local haml gem processor as a pre- >>> processor for .haml files outside of Rails as well, so I could develop >>> all of my HTML code with this incredible markup.
>>> The idea is that all files with the suffix .haml should be processed >>> through haml, while the rest will retain their original processing. I >>> tried adding the following lines to my .htaccess file (on Dreamhost) >>> without success:
>>> This gives me a slow response, and a "Rails application failed to >>> start properly" error, in a directory where I have not installed any >>> Rails code. Can anyone spot the problem? If so, I'd love to get this >>> working!
I guess with some mod_rewrite logic this can be boosted way better that executing the script each time.
But executing it locally (without apache) and measuring time for a very simple test.haml file gave me the about 17s for the first hit, and 0.03sec for following attempts. So its pretty speedy for a CGI wrapper.
*just use the time command in unix*
- evgeny
On 7/30/07, Sean Cribbs <seancri...@gmail.com> wrote:
> Awesome! You might get an even better performance boost if you can move > the timestamp checking into the Apache configuration, perhaps as rewrite > rules. I imagine it can be done, I'm just not a mod_rewrite whiz.
> On 7/30/07, Sean Cribbs <seancri...@gmail.com> wrote:
> IIRC, the Haml command line utility outputs to another file by > default. Since CGI uses stdin/out, you'd have to pass some options to > Haml to force it to use stdout, or write a script that acts as the > handler and does that for you. Keep in mind that Ruby's CGI interface > is really slow w.r.t. Apache -- a new interpreter has to be spawned > every time there is a request. I would suggest implementing some sort > of caching, perhaps as part of the initial request.
> Sean
> On 7/29/07, Mike Zillion <mikezill...@gmail.com> wrote:
> This sounded like a fun idea, but no luck yet.
> I'm thoroughly enjoying HAML and SASS in my Rails application > development. I wanted to use my local haml gem processor as a pre- > processor for .haml files outside of Rails as well, so I could develop > all of my HTML code with this incredible markup.
> The idea is that all files with the suffix .haml should be processed > through haml, while the rest will retain their original processing. I > tried adding the following lines to my .htaccess file (on Dreamhost) > without success:
> This gives me a slow response, and a "Rails application failed to > start properly" error, in a directory where I have not installed any > Rails code. Can anyone spot the problem? If so, I'd love to get this > working!