heist 0.13.0 → 0.13.0.1
raw patch · 2 files changed
+13/−7 lines, 2 filesPVP: minor bump suggested
API additions: PVP suggests at least a minor version bump
API changes (from Hackage documentation)
+ Heist.SpliceAPI: add :: Map Text s -> Splices s
Files
- heist.cabal +1/−1
- src/Heist/SpliceAPI.hs +12/−6
heist.cabal view
@@ -1,5 +1,5 @@ name: heist-version: 0.13.0+version: 0.13.0.1 synopsis: An Haskell template system supporting both HTML5 and XML. description: Heist is a powerful template system that supports both HTML5 and XML.
src/Heist/SpliceAPI.hs view
@@ -25,7 +25,7 @@ module Heist.SpliceAPI where -import Control.Monad.State+import Control.Monad.State (State, MonadState, execState, modify) import Data.Map (Map) import qualified Data.Map as M import Data.Monoid@@ -81,7 +81,7 @@ ------------------------------------------------------------------------------ -- | A `Splices` with nothing in it. noSplices :: Splices s-noSplices = put M.empty+noSplices = return () ------------------------------------------------------------------------------@@ -97,9 +97,15 @@ ------------------------------------------------------------------------------+-- | Internal helper function for adding a map.+add :: Map Text s -> Splices s+add m = modify (\s -> M.unionWith (\_ b -> b) s m)+++------------------------------------------------------------------------------ -- | Maps a function over all the splices. mapS :: (a -> b) -> Splices a -> Splices b-mapS f ss = put $ M.map f $ runSplices ss +mapS f ss = add $ M.map f $ runSplices ss ------------------------------------------------------------------------------@@ -117,13 +123,13 @@ ------------------------------------------------------------------------------ -- | Inserts a splice with a function combining new value and old value. insertWithS :: (s -> s -> s) -> Text -> s -> SplicesM s a2 -> SplicesM s ()-insertWithS f k v b = put $ M.insertWith f k v (runSplices b)+insertWithS f k v b = add $ M.insertWith f k v (runSplices b) ------------------------------------------------------------------------------ -- | Union of `Splices` with a combining function. unionWithS :: (s -> s -> s) -> SplicesM s a1 -> SplicesM s a2 -> SplicesM s ()-unionWithS f a b = put $ M.unionWith f (runSplices a) (runSplices b)+unionWithS f a b = add $ M.unionWith f (runSplices a) (runSplices b) ------------------------------------------------------------------------------@@ -136,7 +142,7 @@ ------------------------------------------------------------------------------ -- | Maps a function over all the splice names. mapNames :: (Text -> Text) -> Splices a -> Splices a-mapNames f = put . M.mapKeys f . runSplices+mapNames f = add . M.mapKeys f . runSplices -- The following two functions are formulated as functions of Splices instead