-- Hoogle documentation, generated by Haddock
-- See Hoogle, http://www.haskell.org/hoogle/


-- | Support for using Heist templates in Happstack
--   
--   Happstack is a web application framework. Heist is an XML templating
--   solution. This package makes it easy to use Heist templates with
--   Happstack.
@package happstack-heist
@version 7.2.0


-- | This module provides support for serving compiled Heist templates
--   using Happstack.
--   
--   The primary function provided by this module is:
--   
--   heistServe :: (Happstack m) =&gt; HeistState m -&gt; m Response
--   
--   It also provides the <a>initHeistCompiled</a> helper function for
--   creating a <a>HeistState</a>. Though you are free to use other
--   functions from the Heist library instead.
--   
--   Here is a simple example:
--   
--   <pre>
--   module Main where
--   
--   import Control.Applicative    ((&lt;$&gt;))
--   import Control.Monad          (msum)
--   import qualified Data.Text    as T
--   import Happstack.Server       (dir, nullConf, nullDir, simpleHTTP, seeOther, toResponse)
--   import Happstack.Server.Heist (heistServe, initHeistCompiled)
--   import Heist                  ((##), getParamNode, noSplices)
--   import Heist.Compiled         (Splice, yieldRuntimeText)
--   import qualified Text.XmlHtml as X
--   
--   -- | factorial splice
--   factSplice :: (Monad m) =&gt; Splice m
--   factSplice =
--       do intStr &lt;- T.unpack . X.nodeText &lt;$&gt; getParamNode
--          let res = yieldRuntimeText $
--                      do case reads intStr of
--                           [(n,[])] -&gt;
--                               return (T.pack $ show $ product [1..(n :: Integer)])
--                           _ -&gt;
--                               return (T.pack $ "Unable to parse " ++ intStr ++ " as an Integer.")
--          return $ res
--   
--   main :: IO ()
--   main =
--     do heistState &lt;- do
--          r &lt;- initHeistCompiled (T.pack "fact" ## factSplice) noSplices "."
--          case r of
--            (Left e) -&gt; error $ unlines e
--            (Right heistState) -&gt; return $ heistState
--        simpleHTTP nullConf $ msum
--          [ dir "heist" $ heistServe heistState
--          , nullDir &gt;&gt; seeOther "/heist/factorial" (toResponse "/heist/factorial")
--          ]
--   </pre>
--   
--   It uses the following template file (<tt>factorial.tpl</tt>):
--   
--   <pre>
--   &lt;html&gt;
--     &lt;head&gt;
--       &lt;title&gt;Factorial Page&lt;/title&gt;
--     &lt;/head&gt;
--     &lt;body&gt;
--       &lt;h1&gt;Factorial Page&lt;/h1&gt;
--       &lt;p&gt;The factorial of 6 is &lt;fact&gt;6&lt;/fact&gt;&lt;/p&gt;
--     &lt;/body&gt;
--   &lt;/html&gt;
--   </pre>
--   
--   For more information on using Compiled Heist Templates see:
--   
--   <a>http://snapframework.com/docs/tutorials/compiled-splices</a>
--   
--   And also see the Heist Section of the Happstack Crash Course:
--   
--   <a>http://happstack.com/docs/crashcourse/</a>
module Happstack.Server.Heist
initHeistCompiled :: (MonadIO m, Monad n) => Splices (Splice n) -> Splices (AttrSplice n) -> FilePath -> m (Either [String] (HeistState n))
heistServe :: Happstack m => HeistState m -> m Response
