yesodweb/yesod — pull request #255 by gregwebs (2012-02-06 04:43:54+00:00)
Title: support static page route parsing

Hopefully you can see from the test case what I am getting at. Note that I added the ability for all routing to imply a route prefix through indentation.

I run the generated paths against a Yesod app and write out the file.

~~~ {.haskell}
renderStaticPages :: FilePath -> IO ()
renderStaticPages directory = do
app <- toWaiAppPlain StaticPages
flip mapM_ staticPageRoutePaths $ \path -> do
let req = setRawPathInfo defaultRequest $ BS8.pack $ path
rsp <- runResourceT $ app req
case rsp of
ResponseBuilder _ _ b ->
LBS.writeFile (directory ++ (BS8.unpack $ rawPathInfo req) ++ ".html") $ toLazyByteString b
_ -> error "expected ResponseBuilder"
~~~

Not sure where that code should go.

This is all still experimental - I am hoping to get some feedback as I improve the integration.