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, master has been updated
       via  f95fa7b8315eff5e19bc76e952cb33d2a5099556 (commit)
       via  b965a37da1ef4737382aab29e210c99eb9918cd3 (commit)
      from  3048641f640084cec83adc27743b33ec1780d125 (commit)


Summary of changes:
 .ghci                                      |    2 -
 src/Text/Templating/Heist/Internal.hs      |    9 +-----
 src/Text/Templating/Heist/Splices/Apply.hs |   41 ++++++++++++++++-----------
 test/heist-testsuite.cabal                 |    1 +
 4 files changed, 27 insertions(+), 26 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 f95fa7b8315eff5e19bc76e952cb33d2a5099556
Author: Mighty Byte <[email protected]>
Date:   Mon Mar 21 10:56:07 2011 -0400

    Refactor implementation of apply splice so it can be called from code.

diff --git a/.ghci b/.ghci
index d356473..2e44db4 100644
--- a/.ghci
+++ b/.ghci
@@ -2,5 +2,3 @@
 :set -Wall
 :set -isrc
 :set -itest/suite
-:set -hide-package mtl
-:set -hide-package MonadCatchIO-mtl
diff --git a/src/Text/Templating/Heist/Internal.hs 
b/src/Text/Templating/Heist/Internal.hs
index 62df758..bc64006 100644
--- a/src/Text/Templating/Heist/Internal.hs
+++ b/src/Text/Templating/Heist/Internal.hs
@@ -393,7 +393,6 @@ getAttributeSplice name = do
 -- | Performs splice processing on a list of nodes.
 runNodeList :: Monad m => [X.Node] -> Splice m
 runNodeList = mapSplices runNode
---runNodeList nodes = liftM concat $ sequence (map runNode nodes)
 
 
 ------------------------------------------------------------------------------
@@ -439,12 +438,8 @@ evalTemplate :: Monad m
             => ByteString
             -> TemplateMonad m (Maybe Template)
 evalTemplate name = lookupAndRun name
-    (\(t,ctx) -> do
-        ts <- getTS
-        putTS (ts {_curContext = ctx})
-        res <- runNodeList $ X.docContent t
-        restoreTS ts
-        return $ Just res)
+    (\(t,ctx) -> localTS (\ts -> ts {_curContext = ctx})
+                         (liftM Just $ runNodeList $ X.docContent t))
 
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Apply.hs 
b/src/Text/Templating/Heist/Splices/Apply.hs
index d5a4f80..97d6075 100644
--- a/src/Text/Templating/Heist/Splices/Apply.hs
+++ b/src/Text/Templating/Heist/Splices/Apply.hs
@@ -24,28 +24,35 @@ applyAttr = "template"
 
 
 ------------------------------------------------------------------------------
+-- | Applies a template as if the supplied nodes were the children of the
+-- <apply> tag.
+applyNodes :: Monad m => Template -> Text -> Splice m
+applyNodes nodes template = do
+    st <- getTS
+    maybe (return []) -- TODO: error handling
+          (\(t,ctx) -> do
+              addDoctype $ maybeToList $ X.docType t
+              processedChildren <- runNodeList nodes
+              modifyTS (bindSplice "content" $
+                        return processedChildren)
+              setContext ctx
+              result <- runNodeList $ X.docContent t
+              restoreTS st
+              return result)
+          (lookupTemplate (T.encodeUtf8 template)
+                          (st {_curContext = nextCtx template st}))
+  where nextCtx name st
+            | T.isPrefixOf "/" name = []
+            | otherwise             = _curContext st
+
+
+------------------------------------------------------------------------------
 -- | Implementation of the apply splice.
 applyImpl :: Monad m => Splice m
 applyImpl = do
     node <- getParamNode
     case X.getAttribute applyAttr node of
         Nothing   -> return [] -- TODO: error handling
-        Just attr -> do
-            st <- getTS
-            maybe (return []) -- TODO: error handling
-                  (\(t,ctx) -> do
-                      addDoctype $ maybeToList $ X.docType t
-                      processedChildren <- runNodeList $ X.childNodes node
-                      modifyTS (bindSplice "content" $
-                                return processedChildren)
-                      setContext ctx
-                      result <- runNodeList $ X.docContent t
-                      restoreTS st
-                      return result)
-                  (lookupTemplate (T.encodeUtf8 attr)
-                                  (st {_curContext = nextCtx attr st}))
-  where nextCtx name st
-            | T.isPrefixOf "/" name = []
-            | otherwise             = _curContext st
+        Just template -> applyNodes (X.childNodes node) template
 
 
commit b965a37da1ef4737382aab29e210c99eb9918cd3
Author: Mighty Byte <[email protected]>
Date:   Mon Mar 21 10:55:42 2011 -0400

    Add time dependency to test package.

diff --git a/test/heist-testsuite.cabal b/test/heist-testsuite.cabal
index 0bb6cfc..beba655 100644
--- a/test/heist-testsuite.cabal
+++ b/test/heist-testsuite.cabal
@@ -28,6 +28,7 @@ Executable testsuite
      test-framework-hunit >= 0.2.5 && < 0.3,
      test-framework-quickcheck2 >= 0.2.6 && < 0.3,
      text >= 0.10 && < 0.12,
+     time,
      transformers
      
    ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded
-----------------------------------------------------------------------


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

Reply via email to