Run Sinatra via a Rake Task to Generate Static Files?
Posted
by viatropos
on Stack Overflow
See other posts from Stack Overflow
or by viatropos
Published on 2010-03-09T00:17:14Z
Indexed on
2010/03/09
0:21 UTC
Read the original article
Hit count: 547
I'm not sure I can put this correctly but I'll give it a shot.
I want to use Sinatra to generate static html files once I am ready to deploy an application, so the resulting final website would be pure static HTML. During development, however, I want everything to be dynamic so I can use Haml and straight Ruby code to make things fast/dry/clear. I don't want to use Jekyll or some of the other static site generators out there because they don't have as much power as Sinatra.
So all I basically need to be able to do is run a rake task such as:
rake sinatra:generate_static_files
.
That would run the render
commands for Haml and everything else, and the result would be written to files.
My question is, how do I do that with Sinatra in a Rake task? Can I do it in a Rake task? The problem is, I don't know how to include the Sinatra::Application
in the rake task... The only other way I could think of doing it is using net/http
to access a URL that does all of that, but that seems like overkill.
Any ideas how on to solve this?
© Stack Overflow or respective owner