Skip to content
Browse files

Added modifyHeistTS

  • Loading branch information...
1 parent c0052b0 commit 5725a7739a487ebd47f1714ae80febf3bacf8d81 @mightybyte mightybyte committed Oct 15, 2011
Showing with 24 additions and 0 deletions.
  1. +10 −0 src/Snap/Snaplet/Heist.hs
  2. +14 −0 src/Snap/Snaplet/HeistNoClass.hs
View
10 src/Snap/Snaplet/Heist.hs
@@ -101,6 +101,16 @@ addSplices :: (HasHeist b)
addSplices = Unclassed.addSplices' heistLens
+------------------------------------------------------------------------------
+-- | More general function allowing arbitrary TemplateState modification.
+-- Without this function you wouldn't be able to bind more complicated splices
+-- like the cache tag.
+modifyHeistTS :: (HasHeist b)
+ => (TemplateState (Handler b b) -> TemplateState (Handler b b))
+ -> Initializer b v ()
+modifyHeistTS = Unclassed.modifyHeistTS' heistLens
+
+
-- $handlerSection
-- This section contains functions in the 'Handler' monad that you'll use in
-- processing requests.
View
14 src/Snap/Snaplet/HeistNoClass.hs
@@ -227,6 +227,20 @@ addTemplatesAt urlPrefix templateDir = do
(`mappend` addTemplatePathPrefix urlPrefix ts)
+modifyHeistTS' :: (Lens (Snaplet b) (Snaplet (Heist b)))
+ -> (TemplateState (Handler b b) -> TemplateState (Handler b b))
+ -> Initializer b v ()
+modifyHeistTS' heist f = do
+ _lens <- getLens
+ withTop' heist $ addPostInitHook $ return . changeTS f
+
+
+modifyHeistTS :: (Lens b (Snaplet (Heist b)))
+ -> (TemplateState (Handler b b) -> TemplateState (Handler b b))
+ -> Initializer b v ()
+modifyHeistTS heist f = modifyHeist' (subSnaplet heist) f
+
+
addSplices' :: (Lens (Snaplet b) (Snaplet (Heist b)))
-> [(Text, SnapletSplice b v)]
-> Initializer b v ()

0 comments on commit 5725a77

Please sign in to comment.
Something went wrong with that request. Please try again.