This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "heist".

The branch, 0.2-dev has been updated
       via  aae6986117305fa685d0d04dd08b21ef5e53cf25 (commit)
      from  a47a25d653b5230f3789f1ad9f1d11b85954759c (commit)


Summary of changes:
 src/Text/Templating/Heist/Internal.hs      |   46 +++++++++++----------------
 src/Text/Templating/Heist/Splices/Apply.hs |    3 +-
 2 files changed, 20 insertions(+), 29 deletions(-)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit aae6986117305fa685d0d04dd08b21ef5e53cf25
Author: Mighty Byte <[email protected]>
Date:   Sun May 30 11:07:52 2010 -0400

    Fixed bug, added comments, reordered code.

diff --git a/src/Text/Templating/Heist/Internal.hs 
b/src/Text/Templating/Heist/Internal.hs
index 7860765..2080440 100644
--- a/src/Text/Templating/Heist/Internal.hs
+++ b/src/Text/Templating/Heist/Internal.hs
@@ -144,6 +144,21 @@ runTemplateMonad ts node (TemplateMonad tm) = do
 
 
 ------------------------------------------------------------------------------
+-- | Restores the components of TemplateState that can get modified in
+-- template calls.  You should use this function instead of @put@ to restore
+-- an old state.  Thas was needed because doctypes needs to be in a "global
+-- scope" as opposed to the template call "local scope" of state items such
+-- as recursionDepth, curContext, and spliceMap.
+restoreState :: Monad m => TemplateState m -> TemplateMonad m ()
+restoreState ts1 = 
+    modify (\ts2 -> ts2
+        { _recursionDepth = _recursionDepth ts1
+        , _curContext = _curContext ts1
+        , _spliceMap = _spliceMap ts1
+        })
+
+
+------------------------------------------------------------------------------
 -- | Mappends a doctype to the state.
 addDoctype :: Monad m => [ByteString] -> TemplateMonad m ()
 addDoctype dt = do
@@ -376,33 +391,6 @@ mAX_RECURSION_DEPTH :: Int
 mAX_RECURSION_DEPTH = 50
 
 
-modRecursionDepth :: Monad m => (Int -> Int) -> TemplateMonad m ()
-modRecursionDepth f =
-    modify (\st -> st { _recursionDepth = f (_recursionDepth st) })
-
-
-restoreState :: Monad m => TemplateState m -> TemplateMonad m ()
-restoreState ts1 = 
-    modify (\ts2 -> ts2
-        { _recursionDepth = _recursionDepth ts1
-        , _curContext = _curContext ts1
-        , _spliceMap = _spliceMap ts1
-        })
-
-
-call :: Monad m => TemplateMonad m a -> TemplateMonad m a
-call k = do
-    ts <- get
-    let rd = _recursionDepth ts
-        cc = _curContext ts
-        sm = _spliceMap ts
-    res <- k
-    put $ ts { _recursionDepth = rd 
-             , _curContext = cc
-             , _spliceMap = sm
-             }
-    return res
-    
 ------------------------------------------------------------------------------
 -- | Checks the recursion flag and recurses accordingly.  Does not recurse
 -- deeper than mAX_RECURSION_DEPTH to avoid infinite loops.
@@ -416,6 +404,10 @@ recurseSplice node splice = do
                 restoreState ts'
                 return res
         else return result
+  where
+    modRecursionDepth :: Monad m => (Int -> Int) -> TemplateMonad m ()
+    modRecursionDepth f =
+        modify (\st -> st { _recursionDepth = f (_recursionDepth st) })
 
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Apply.hs 
b/src/Text/Templating/Heist/Splices/Apply.hs
index 00b8cad..6633753 100644
--- a/src/Text/Templating/Heist/Splices/Apply.hs
+++ b/src/Text/Templating/Heist/Splices/Apply.hs
@@ -36,12 +36,11 @@ applyImpl = do
             maybe (return []) -- TODO: error handling
                   (\(t,ctx) -> do
                       addDoctype $ maybeToList $ _itDoctype t
-                      st' <- get
                       processedChildren <- runNodeList $ X.getChildren node
                       modify (bindSplice "content" $ return processedChildren)
                       setContext ctx
                       result <- runNodeList $ _itNodes t
-                      restoreState st'
+                      restoreState st
                       return result)
                   (lookupTemplate attr (st {_curContext = nextCtx attr st}))
   where nextCtx name st
-----------------------------------------------------------------------


hooks/post-receive
-- 
heist
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to