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  8860e06654c70caf3c93ce0ea630ffb1d7d57f3c (commit)
       via  7bcd14840952ebdf4c1baa621e384e3a9f7d89ee (commit)
       via  e49d38897c443ad01a67b50a960a083d87cfd240 (commit)
       via  ab0855fd1f1464a93770c8aab08b4d8a84f7e7a4 (commit)
      from  feef2878249a5925501aff397c9448b42b3f3fd3 (commit)


Summary of changes:
 src/Text/Templating/Heist/Splices/Apply.hs |   21 ++++++++++++++-------
 src/Text/Templating/Heist/Splices/Bind.hs  |    6 +++++-
 test/heist-testsuite.cabal                 |    2 +-
 test/suite/Text/Templating/Heist/Tests.hs  |   16 +++++++++++++++-
 test/templates/bind_param.tpl              |    1 +
 test/templates/div_expansion.tpl           |    1 +
 6 files changed, 37 insertions(+), 10 deletions(-)
 create mode 100644 test/templates/bind_param.tpl
 create mode 100644 test/templates/div_expansion.tpl

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 8860e06654c70caf3c93ce0ea630ffb1d7d57f3c
Author: Mighty Byte <[email protected]>
Date:   Fri Apr 8 00:58:17 2011 -0400

    Forgot to add a couple files.

diff --git a/test/suite/Text/Templating/Heist/Tests.hs 
b/test/suite/Text/Templating/Heist/Tests.hs
index b174036..a260a5f 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -57,6 +57,7 @@ tests = [ testProperty "heist/simpleBind"            
simpleBindTest
         , testCase     "heist/markdown"              markdownTest
         , testCase     "heist/title_expansion"       titleExpansion
         , testCase     "heist/textarea_expansion"    textareaExpansion
+        , testCase     "heist/div_expansion"         divExpansion
         , testCase     "heist/bind_param"            bindParam
         , testCase     "heist/markdownText"          markdownTextTest
         , testCase     "heist/apply"                 applyTest
@@ -254,6 +255,12 @@ textareaExpansion = renderTest "textarea_expansion" 
"<textarea>foo</textarea>"
 
 
 ------------------------------------------------------------------------------
+-- | Expansion of a bound name inside a div-tag
+divExpansion :: H.Assertion
+divExpansion = renderTest "div_expansion" "<div>foo</div>"
+
+
+------------------------------------------------------------------------------
 -- | Handling of <content> and bound parameters in a bonud tag.
 bindParam :: H.Assertion
 bindParam = renderTest "bind_param" "<li>Hi there world</li>"
diff --git a/test/templates/bind_param.tpl b/test/templates/bind_param.tpl
new file mode 100644
index 0000000..36ca687
--- /dev/null
+++ b/test/templates/bind_param.tpl
@@ -0,0 +1 @@
+<bind tag="item"><li><content/> <foo/></li></bind><item><bind 
tag="foo">world</bind>Hi there<bind tag="bar">hello</bind></item>
diff --git a/test/templates/div_expansion.tpl b/test/templates/div_expansion.tpl
new file mode 100644
index 0000000..956b97a
--- /dev/null
+++ b/test/templates/div_expansion.tpl
@@ -0,0 +1 @@
+<bind tag="mytext">foo</bind><div><mytext/></div>
commit 7bcd14840952ebdf4c1baa621e384e3a9f7d89ee
Author: Mighty Byte <[email protected]>
Date:   Fri Apr 8 00:53:26 2011 -0400

    Added test for new bind functionality.

diff --git a/test/heist-testsuite.cabal b/test/heist-testsuite.cabal
index beba655..b9c2980 100644
--- a/test/heist-testsuite.cabal
+++ b/test/heist-testsuite.cabal
@@ -21,7 +21,7 @@ Executable testsuite
      filepath,
      xmlhtml == 0.1.*,
      HUnit >= 1.2 && < 2,
-     monads-fd,
+     mtl >= 2,
      random,
      MonadCatchIO-transformers >= 0.2.1 && < 0.3,
      test-framework >= 0.3.1 && <0.4,
diff --git a/test/suite/Text/Templating/Heist/Tests.hs 
b/test/suite/Text/Templating/Heist/Tests.hs
index b98cc6f..b174036 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -57,6 +57,7 @@ tests = [ testProperty "heist/simpleBind"            
simpleBindTest
         , testCase     "heist/markdown"              markdownTest
         , testCase     "heist/title_expansion"       titleExpansion
         , testCase     "heist/textarea_expansion"    textareaExpansion
+        , testCase     "heist/bind_param"            bindParam
         , testCase     "heist/markdownText"          markdownTextTest
         , testCase     "heist/apply"                 applyTest
         , testCase     "heist/ignore"                ignoreTest
@@ -133,7 +134,7 @@ loadTest = do
     ets <- loadT "templates"
     either (error "Error loading templates")
            (\ts -> do let tm = _templateMap ts
-                      H.assertBool "loadTest size" $ Map.size tm == 19
+                      H.assertBool "loadTest size" $ Map.size tm == 21
            ) ets
 
 
@@ -253,6 +254,12 @@ textareaExpansion = renderTest "textarea_expansion" 
"<textarea>foo</textarea>"
 
 
 ------------------------------------------------------------------------------
+-- | Handling of <content> and bound parameters in a bonud tag.
+bindParam :: H.Assertion
+bindParam = renderTest "bind_param" "<li>Hi there world</li>"
+
+
+------------------------------------------------------------------------------
 -- | Markdown test on supplied text
 markdownTextTest :: H.Assertion
 markdownTextTest = do
commit e49d38897c443ad01a67b50a960a083d87cfd240
Author: Mighty Byte <[email protected]>
Date:   Fri Apr 8 00:29:45 2011 -0400

    Bind modified to have bound tags accept parameters.

diff --git a/src/Text/Templating/Heist/Splices/Bind.hs 
b/src/Text/Templating/Heist/Splices/Bind.hs
index 0010600..8904895 100644
--- a/src/Text/Templating/Heist/Splices/Bind.hs
+++ b/src/Text/Templating/Heist/Splices/Bind.hs
@@ -23,26 +23,17 @@ bindAttr = "tag"
 ------------------------------------------------------------------------------
 -- | Implementation of the bind splice.
 bindImpl :: Monad m => Splice m
-bindImpl = generalBind add
-  where
-    add node nm = do
-        modifyTS $ bindSplice nm (return $ X.childNodes node)
-        return []
-
-
-generalBind :: Monad m => (X.Node -> Text -> Splice m) -> Splice m
-generalBind k = do
+bindImpl = do
     node <- getParamNode
-    maybe (return [])
-          (k node)
+    maybe (return ())
+          (add node)
           (X.getAttribute bindAttr node)
+    return []
 
-
-bindImplNew :: Monad m => Splice m
-bindImplNew = generalBind action
   where
-    action node nm = do --unused nm might be a bug
+    add node nm = modifyTS $ bindSplice nm $ do
         caller <- getParamNode
         ctx <- getContext
         rawApply (X.childNodes node) ctx (X.childNodes caller)
 
+
commit ab0855fd1f1464a93770c8aab08b4d8a84f7e7a4
Author: Mighty Byte <[email protected]>
Date:   Thu Apr 7 19:00:48 2011 -0400

    Working on new bind.

diff --git a/src/Text/Templating/Heist/Splices/Apply.hs 
b/src/Text/Templating/Heist/Splices/Apply.hs
index 97d6075..33a9d79 100644
--- a/src/Text/Templating/Heist/Splices/Apply.hs
+++ b/src/Text/Templating/Heist/Splices/Apply.hs
@@ -24,6 +24,19 @@ applyAttr = "template"
 
 
 ------------------------------------------------------------------------------
+-- | Raw core of apply functionality.  This is abstracted for use in other
+-- places like an enhanced (from the original) bind
+rawApply calledNodes newContext paramNodes = do
+    st <- getTS  -- Can't use localTS here because the modifier is not pure
+    processedParams <- runNodeList paramNodes
+    modifyTS (bindSplice "content" $ return processedParams)
+    setContext newContext
+    result <- runNodeList calledNodes
+    restoreTS st
+    return result
+
+
+------------------------------------------------------------------------------
 -- | Applies a template as if the supplied nodes were the children of the
 -- <apply> tag.
 applyNodes :: Monad m => Template -> Text -> Splice m
@@ -32,13 +45,7 @@ applyNodes nodes template = do
     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)
+              rawApply (X.docContent t) ctx nodes)
           (lookupTemplate (T.encodeUtf8 template)
                           (st {_curContext = nextCtx template st}))
   where nextCtx name st
diff --git a/src/Text/Templating/Heist/Splices/Bind.hs 
b/src/Text/Templating/Heist/Splices/Bind.hs
index a4ab089..0010600 100644
--- a/src/Text/Templating/Heist/Splices/Bind.hs
+++ b/src/Text/Templating/Heist/Splices/Bind.hs
@@ -6,6 +6,7 @@ import qualified Text.XmlHtml as X
 
 ------------------------------------------------------------------------------
 import           Text.Templating.Heist.Internal
+import           Text.Templating.Heist.Splices.Apply
 import           Text.Templating.Heist.Types
 
 -- | Default name for the bind splice.
@@ -22,14 +23,26 @@ bindAttr = "tag"
 ------------------------------------------------------------------------------
 -- | Implementation of the bind splice.
 bindImpl :: Monad m => Splice m
-bindImpl = do
+bindImpl = generalBind add
+  where
+    add node nm = do
+        modifyTS $ bindSplice nm (return $ X.childNodes node)
+        return []
+
+
+generalBind :: Monad m => (X.Node -> Text -> Splice m) -> Splice m
+generalBind k = do
     node <- getParamNode
-    maybe (return ())
-          (add node)
+    maybe (return [])
+          (k node)
           (X.getAttribute bindAttr node)
-    return []
 
-  where
-    add node nm = modifyTS $ bindSplice nm (return $ X.childNodes node)
 
+bindImplNew :: Monad m => Splice m
+bindImplNew = generalBind action
+  where
+    action node nm = do --unused nm might be a bug
+        caller <- getParamNode
+        ctx <- getContext
+        rawApply (X.childNodes node) ctx (X.childNodes caller)
 
-----------------------------------------------------------------------


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

Reply via email to