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  07363490c4cfa752103f5e2f56d4cc8e139b9b4f (commit)
       via  ab611758a3a8a8355301d7a23a695699584df3b8 (commit)
       via  2f482b546903d64ed4b571346701a908b28a08ff (commit)
       via  0a96dc072acb95bfb4ba8db3c1951a41d8aeaf00 (commit)
       via  64f9c0446f8c03df274c17b229d9dd9169bb07b2 (commit)
       via  ea39123c6ee3cc9e4478e6cddd85ddd168103c84 (commit)
       via  067dedede87d3d3dce2a4a81074fd2940ad0008a (commit)
       via  90d20a6fc869a46bdbf205a55f59b5f2ccf11e47 (commit)
      from  8ddb3008ed8357f2fc3c557e3ecd209caed5d36f (commit)


Summary of changes:
 heist.cabal                                   |    5 ++-
 src/Text/Templating/Heist.hs                  |    5 ++-
 src/Text/Templating/Heist/Internal.hs         |    1 -
 src/Text/Templating/Heist/Splices.hs          |    2 +
 src/Text/Templating/Heist/Splices/Apply.hs    |    2 -
 src/Text/Templating/Heist/Splices/Bind.hs     |    2 -
 src/Text/Templating/Heist/Splices/Html.hs     |   47 +++++++++++++++++++++++++
 src/Text/Templating/Heist/Splices/Ignore.hs   |    2 -
 src/Text/Templating/Heist/Splices/Markdown.hs |    2 +-
 src/Text/Templating/Heist/Splices/Static.hs   |    2 -
 src/Text/Templating/Heist/Types.hs            |    1 -
 test/heist-testsuite.cabal                    |    1 +
 test/suite/Text/Templating/Heist/Tests.hs     |   29 +++++++++++++--
 test/templates/textarea_expansion.tpl         |    1 +
 test/templates/title_expansion.tpl            |    1 +
 15 files changed, 85 insertions(+), 18 deletions(-)
 create mode 100644 src/Text/Templating/Heist/Splices/Html.hs
 create mode 100644 test/templates/textarea_expansion.tpl
 create mode 100644 test/templates/title_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 07363490c4cfa752103f5e2f56d4cc8e139b9b4f
Author: Mighty Byte <[email protected]>
Date:   Sat Mar 5 20:48:57 2011 -0500

    Added OverloadedStrings to the test suite's .cabal.

diff --git a/test/heist-testsuite.cabal b/test/heist-testsuite.cabal
index 9da3caf..0bb6cfc 100644
--- a/test/heist-testsuite.cabal
+++ b/test/heist-testsuite.cabal
@@ -31,4 +31,5 @@ Executable testsuite
      transformers
      
    ghc-options: -O2 -Wall -fhpc -fwarn-tabs -funbox-strict-fields -threaded
+   Extensions: OverloadedStrings
 
commit ab611758a3a8a8355301d7a23a695699584df3b8
Merge: 2f482b5 ea39123
Author: Mighty Byte <[email protected]>
Date:   Sat Mar 5 20:39:48 2011 -0500

    Merge https://github.com/sol/heist

commit 2f482b546903d64ed4b571346701a908b28a08ff
Author: Mighty Byte <[email protected]>
Date:   Thu Mar 3 11:46:22 2011 -0500

    Nub the head list to remove duplicates.

diff --git a/src/Text/Templating/Heist/Splices/Html.hs 
b/src/Text/Templating/Heist/Splices/Html.hs
index 9529220..95688e8 100644
--- a/src/Text/Templating/Heist/Splices/Html.hs
+++ b/src/Text/Templating/Heist/Splices/Html.hs
@@ -1,6 +1,7 @@
 module Text.Templating.Heist.Splices.Html where
 
 ------------------------------------------------------------------------------
+import           Data.List
 import           Data.Maybe
 import           Data.Text (Text)
 import qualified Text.XmlHtml as X
@@ -25,7 +26,8 @@ htmlImpl = do
     node <- getParamNode
     children <- runNodeList $ X.childNodes node
     let (heads, mnode) = extractHeads $ node { X.elementChildren = children }
-        new (X.Element t a c) = X.Element t a (X.Element "head" [] heads : c)
+        new (X.Element t a c) = X.Element t a $
+            X.Element "head" [] (nub heads) : c
         new n = n
     return [maybe node new mnode]
 
commit 0a96dc072acb95bfb4ba8db3c1951a41d8aeaf00
Author: Mighty Byte <[email protected]>
Date:   Thu Mar 3 11:40:05 2011 -0500

    Added OverloadedStrings to the .cabal file since it's used pretty much 
everwhere.

diff --git a/heist.cabal b/heist.cabal
index 31f34f7..9c52e7a 100644
--- a/heist.cabal
+++ b/heist.cabal
@@ -102,6 +102,8 @@ Library
   else
     ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2
 
+  Extensions: OverloadedStrings
+
 
 source-repository head
   type:     git
diff --git a/src/Text/Templating/Heist.hs b/src/Text/Templating/Heist.hs
index d5f2da0..677f580 100644
--- a/src/Text/Templating/Heist.hs
+++ b/src/Text/Templating/Heist.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings, GeneralizedNewtypeDeriving #-}
+{-# LANGUAGE GeneralizedNewtypeDeriving #-}
 
 {-|
 
diff --git a/src/Text/Templating/Heist/Internal.hs 
b/src/Text/Templating/Heist/Internal.hs
index 744ddee..b563fce 100644
--- a/src/Text/Templating/Heist/Internal.hs
+++ b/src/Text/Templating/Heist/Internal.hs
@@ -1,5 +1,4 @@
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
-{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PackageImports #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 
diff --git a/src/Text/Templating/Heist/Splices/Apply.hs 
b/src/Text/Templating/Heist/Splices/Apply.hs
index 07365cd..d5a4f80 100644
--- a/src/Text/Templating/Heist/Splices/Apply.hs
+++ b/src/Text/Templating/Heist/Splices/Apply.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
-
 module Text.Templating.Heist.Splices.Apply where
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Bind.hs 
b/src/Text/Templating/Heist/Splices/Bind.hs
index 2005593..a4ab089 100644
--- a/src/Text/Templating/Heist/Splices/Bind.hs
+++ b/src/Text/Templating/Heist/Splices/Bind.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
-
 module Text.Templating.Heist.Splices.Bind where
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Html.hs 
b/src/Text/Templating/Heist/Splices/Html.hs
index 093ea99..9529220 100644
--- a/src/Text/Templating/Heist/Splices/Html.hs
+++ b/src/Text/Templating/Heist/Splices/Html.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
-
 module Text.Templating.Heist.Splices.Html where
 
 ------------------------------------------------------------------------------
@@ -8,7 +6,8 @@ import           Data.Text (Text)
 import qualified Text.XmlHtml as X
 
 ------------------------------------------------------------------------------
-import           Text.Templating.Heist
+import           Text.Templating.Heist.Internal
+import           Text.Templating.Heist.Types
 
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Ignore.hs 
b/src/Text/Templating/Heist/Splices/Ignore.hs
index 271e61d..940ff2d 100644
--- a/src/Text/Templating/Heist/Splices/Ignore.hs
+++ b/src/Text/Templating/Heist/Splices/Ignore.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
-
 module Text.Templating.Heist.Splices.Ignore where
 
 ------------------------------------------------------------------------------
diff --git a/src/Text/Templating/Heist/Splices/Markdown.hs 
b/src/Text/Templating/Heist/Splices/Markdown.hs
index 9de2e2a..6de1404 100644
--- a/src/Text/Templating/Heist/Splices/Markdown.hs
+++ b/src/Text/Templating/Heist/Splices/Markdown.hs
@@ -1,4 +1,4 @@
-{-# LANGUAGE OverloadedStrings, DeriveDataTypeable #-}
+{-# LANGUAGE DeriveDataTypeable #-}
 
 module Text.Templating.Heist.Splices.Markdown where
 
diff --git a/src/Text/Templating/Heist/Splices/Static.hs 
b/src/Text/Templating/Heist/Splices/Static.hs
index 42782bf..460a17a 100644
--- a/src/Text/Templating/Heist/Splices/Static.hs
+++ b/src/Text/Templating/Heist/Splices/Static.hs
@@ -1,5 +1,3 @@
-{-# LANGUAGE OverloadedStrings #-}
-
 module Text.Templating.Heist.Splices.Static
   ( StaticTagState
   , bindStaticTag
diff --git a/src/Text/Templating/Heist/Types.hs 
b/src/Text/Templating/Heist/Types.hs
index b847bbb..dfb5e4c 100644
--- a/src/Text/Templating/Heist/Types.hs
+++ b/src/Text/Templating/Heist/Types.hs
@@ -1,7 +1,6 @@
 {-# LANGUAGE FlexibleInstances #-}
 {-# LANGUAGE GeneralizedNewtypeDeriving #-}
 {-# LANGUAGE MultiParamTypeClasses #-}
-{-# LANGUAGE OverloadedStrings #-}
 {-# LANGUAGE PackageImports #-}
 {-# LANGUAGE ScopedTypeVariables #-}
 {-# LANGUAGE UndecidableInstances #-}
commit 64f9c0446f8c03df274c17b229d9dd9169bb07b2
Author: Mighty Byte <[email protected]>
Date:   Thu Mar 3 11:31:49 2011 -0500

    Added a built-in splice for the html tag to implement head merging.

diff --git a/heist.cabal b/heist.cabal
index 5e1559b..31f34f7 100644
--- a/heist.cabal
+++ b/heist.cabal
@@ -1,5 +1,5 @@
 name:           heist
-version:        0.5.0.1
+version:        0.5.0.2
 synopsis:       An xhtml templating system
 description:    An xhtml templating system
 license:        BSD3
@@ -68,6 +68,7 @@ Library
     Text.Templating.Heist.Splices,
     Text.Templating.Heist.Splices.Apply,
     Text.Templating.Heist.Splices.Bind,
+    Text.Templating.Heist.Splices.Html,
     Text.Templating.Heist.Splices.Ignore,
     Text.Templating.Heist.Splices.Markdown,
     Text.Templating.Heist.Splices.Static,
diff --git a/src/Text/Templating/Heist.hs b/src/Text/Templating/Heist.hs
index d3cb298..d5f2da0 100644
--- a/src/Text/Templating/Heist.hs
+++ b/src/Text/Templating/Heist.hs
@@ -131,7 +131,8 @@ import           Text.Templating.Heist.Types
 -- | The default set of built-in splices.
 defaultSpliceMap :: MonadIO m => FilePath -> SpliceMap m
 defaultSpliceMap templatePath = Map.fromList
-    [(applyTag, applyImpl)
+    [(htmlTag, htmlImpl)
+    ,(applyTag, applyImpl)
     ,(bindTag, bindImpl)
     ,(ignoreTag, ignoreImpl)
     ,(markdownTag, markdownSplice templatePath)
diff --git a/src/Text/Templating/Heist/Splices.hs 
b/src/Text/Templating/Heist/Splices.hs
index f79c41f..96a0bf5 100644
--- a/src/Text/Templating/Heist/Splices.hs
+++ b/src/Text/Templating/Heist/Splices.hs
@@ -1,6 +1,7 @@
 module Text.Templating.Heist.Splices
   ( module Text.Templating.Heist.Splices.Apply
   , module Text.Templating.Heist.Splices.Bind
+  , module Text.Templating.Heist.Splices.Html
   , module Text.Templating.Heist.Splices.Ignore
   , module Text.Templating.Heist.Splices.Markdown
   , module Text.Templating.Heist.Splices.Static
@@ -8,6 +9,7 @@ module Text.Templating.Heist.Splices
 
 import Text.Templating.Heist.Splices.Apply
 import Text.Templating.Heist.Splices.Bind
+import Text.Templating.Heist.Splices.Html
 import Text.Templating.Heist.Splices.Ignore
 import Text.Templating.Heist.Splices.Markdown
 import Text.Templating.Heist.Splices.Static
diff --git a/src/Text/Templating/Heist/Splices/Html.hs 
b/src/Text/Templating/Heist/Splices/Html.hs
new file mode 100644
index 0000000..093ea99
--- /dev/null
+++ b/src/Text/Templating/Heist/Splices/Html.hs
@@ -0,0 +1,46 @@
+{-# LANGUAGE OverloadedStrings #-}
+
+module Text.Templating.Heist.Splices.Html where
+
+------------------------------------------------------------------------------
+import           Data.Maybe
+import           Data.Text (Text)
+import qualified Text.XmlHtml as X
+
+------------------------------------------------------------------------------
+import           Text.Templating.Heist
+
+
+------------------------------------------------------------------------------
+-- | Name for the html splice.
+htmlTag :: Text
+htmlTag = "html"
+
+
+------------------------------------------------------------------------------
+-- | The html splice runs all children and then traverses the returned node
+-- forest removing all head nodes.  Then it merges them all and prepends it to
+-- the html tag's child list.
+htmlImpl :: Monad m => Splice m
+htmlImpl = do
+    node <- getParamNode
+    children <- runNodeList $ X.childNodes node
+    let (heads, mnode) = extractHeads $ node { X.elementChildren = children }
+        new (X.Element t a c) = X.Element t a (X.Element "head" [] heads : c)
+        new n = n
+    return [maybe node new mnode]
+
+------------------------------------------------------------------------------
+-- | Extracts all heads from a node tree.
+extractHeads :: X.Node
+             -- ^ The root (html) node
+             -> ([X.Node], Maybe X.Node)
+             -- ^ A tuple of a list of head nodes and the original tree with
+             --   heads removed.
+extractHeads (X.Element t a c)
+  | t == "head" = (c, Nothing)
+  | otherwise   = (concat heads, Just $ X.Element t a (catMaybes mcs))
+  where
+    (heads, mcs) = unzip $ map extractHeads c
+extractHeads n = ([], Just n)
+
commit ea39123c6ee3cc9e4478e6cddd85ddd168103c84
Author: Simon Hengel <[email protected]>
Date:   Sun Feb 13 17:11:11 2011 +0100

    Add a failing test case
    
    It shows that expansion of bound names inside a textarea-tag does not
    work.

diff --git a/test/suite/Text/Templating/Heist/Tests.hs 
b/test/suite/Text/Templating/Heist/Tests.hs
index 0f899ea..b98cc6f 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -56,6 +56,7 @@ tests = [ testProperty "heist/simpleBind"            
simpleBindTest
         , testCase     "heist/bindAttribute"         bindAttrTest
         , testCase     "heist/markdown"              markdownTest
         , testCase     "heist/title_expansion"       titleExpansion
+        , testCase     "heist/textarea_expansion"    textareaExpansion
         , testCase     "heist/markdownText"          markdownTextTest
         , testCase     "heist/apply"                 applyTest
         , testCase     "heist/ignore"                ignoreTest
@@ -132,7 +133,7 @@ loadTest = do
     ets <- loadT "templates"
     either (error "Error loading templates")
            (\ts -> do let tm = _templateMap ts
-                      H.assertBool "loadTest size" $ Map.size tm == 18
+                      H.assertBool "loadTest size" $ Map.size tm == 19
            ) ets
 
 
@@ -246,6 +247,12 @@ titleExpansion = renderTest "title_expansion" 
"<title>foo</title>"
 
 
 ------------------------------------------------------------------------------
+-- | Expansion of a bound name inside a textarea-tag
+textareaExpansion :: H.Assertion
+textareaExpansion = renderTest "textarea_expansion" "<textarea>foo</textarea>"
+
+
+------------------------------------------------------------------------------
 -- | Markdown test on supplied text
 markdownTextTest :: H.Assertion
 markdownTextTest = do
diff --git a/test/templates/textarea_expansion.tpl 
b/test/templates/textarea_expansion.tpl
new file mode 100644
index 0000000..148647e
--- /dev/null
+++ b/test/templates/textarea_expansion.tpl
@@ -0,0 +1 @@
+<bind tag="mytext">foo</bind><textarea><mytext/></textarea>
commit 067dedede87d3d3dce2a4a81074fd2940ad0008a
Author: Simon Hengel <[email protected]>
Date:   Sun Feb 13 17:09:36 2011 +0100

    Add a failing test case
    
    It shows that expansion of bound names inside a title-tag does not work.

diff --git a/test/suite/Text/Templating/Heist/Tests.hs 
b/test/suite/Text/Templating/Heist/Tests.hs
index af57e34..0f899ea 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -55,6 +55,7 @@ tests = [ testProperty "heist/simpleBind"            
simpleBindTest
         , testCase     "heist/attributeSubstitution" attrSubstTest
         , testCase     "heist/bindAttribute"         bindAttrTest
         , testCase     "heist/markdown"              markdownTest
+        , testCase     "heist/title_expansion"       titleExpansion
         , testCase     "heist/markdownText"          markdownTextTest
         , testCase     "heist/apply"                 applyTest
         , testCase     "heist/ignore"                ignoreTest
@@ -131,7 +132,7 @@ loadTest = do
     ets <- loadT "templates"
     either (error "Error loading templates")
            (\ts -> do let tm = _templateMap ts
-                      H.assertBool "loadTest size" $ Map.size tm == 17
+                      H.assertBool "loadTest size" $ Map.size tm == 18
            ) ets
 
 
@@ -239,6 +240,12 @@ renderTest templateName expectedResult = do
 
 
 ------------------------------------------------------------------------------
+-- | Expansion of a bound name inside a title-tag
+titleExpansion :: H.Assertion
+titleExpansion = renderTest "title_expansion" "<title>foo</title>"
+
+
+------------------------------------------------------------------------------
 -- | Markdown test on supplied text
 markdownTextTest :: H.Assertion
 markdownTextTest = do
diff --git a/test/templates/title_expansion.tpl 
b/test/templates/title_expansion.tpl
new file mode 100644
index 0000000..187d6d0
--- /dev/null
+++ b/test/templates/title_expansion.tpl
@@ -0,0 +1 @@
+<bind tag="mytext">foo</bind><title><mytext/></title>
commit 90d20a6fc869a46bdbf205a55f59b5f2ccf11e47
Author: Simon Hengel <[email protected]>
Date:   Sun Feb 13 16:47:54 2011 +0100

    Factor out reusable code from markdownTest
    
    With this it is easy to add more tests of that kind.

diff --git a/test/suite/Text/Templating/Heist/Tests.hs 
b/test/suite/Text/Templating/Heist/Tests.hs
index 9618f59..af57e34 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -218,15 +218,22 @@ htmlExpected = "<div class=\'markdown\'><p>This 
<em>is</em> a test.</p></div>"
 ------------------------------------------------------------------------------
 -- | Markdown test on a file
 markdownTest :: H.Assertion
-markdownTest = do
+markdownTest = renderTest "markdown" htmlExpected
+
+
+-- | Render a template and assert that it matches an expected result
+renderTest  :: ByteString   -- ^ template name
+            -> ByteString   -- ^ expected result
+            -> H.Assertion
+renderTest templateName expectedResult = do
     ets <- loadT "templates"
     let ts = either (error "Error loading templates") id ets
 
-    check ts htmlExpected
+    check ts expectedResult
 
   where
     check ts str = do
-        Just (doc, mime) <- renderTemplate ts "markdown"
+        Just (doc, _) <- renderTemplate ts templateName
         let result = B.filter (/= '\n') (toByteString doc)
         H.assertEqual ("Should match " ++ (show str)) str result
 
-----------------------------------------------------------------------


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

Reply via email to