Skip to content

Commit

Permalink
* Snap.Extension.Heist: renderWithSplices convenience function
Browse files Browse the repository at this point in the history
  • Loading branch information
ozataman committed Dec 8, 2010
1 parent 1dc8880 commit fcd8bc9
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion src/Snap/Extension/Heist.hs
Expand Up @@ -18,7 +18,9 @@ always, also your application's monad.
-}

module Snap.Extension.Heist (MonadHeist(..)) where
module Snap.Extension.Heist
( MonadHeist(..)
, renderWithSplices ) where

import Control.Applicative
import Data.ByteString (ByteString)
Expand Down Expand Up @@ -51,3 +53,14 @@ class (Monad n, MonadSnap m) => MonadHeist n m | m -> n where
heistServeSingle :: ByteString -> m ()
heistServeSingle t = render t
<|> error ("Template " ++ show t ++ " not found.")


------------------------------------------------------------------------------
-- | Helper function for common use case:
-- Render a template with a given set of splices.
renderWithSplices
:: (MonadHeist n m) => [(ByteString, Splice n)] -- ^ Splice mapping
-> ByteString -- ^ Template to render
-> m ()
renderWithSplices sps t = heistLocal bsps $ render t
where bsps = bindSplices sps

0 comments on commit fcd8bc9

Please sign in to comment.