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 b889a3be65f81a236484161a4a15a6270ad83e47 (commit)
via b279cabc7e44ba4aca71023e18885edb6e087f87 (commit)
from 8860e06654c70caf3c93ce0ea630ffb1d7d57f3c (commit)
Summary of changes:
src/Text/Templating/Heist/Internal.hs | 3 ++-
src/Text/Templating/Heist/Splices/Apply.hs | 6 +-----
src/Text/Templating/Heist/Types.hs | 6 +-----
test/.ghci | 1 -
test/suite/Text/Templating/Heist/Tests.hs | 15 +++++++++++++++
5 files changed, 19 insertions(+), 12 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 b889a3be65f81a236484161a4a15a6270ad83e47
Author: Mighty Byte <[email protected]>
Date: Sun Apr 10 17:36:04 2011 -0400
Fixed bug in lookupTemplate and added test case to catch it.
diff --git a/src/Text/Templating/Heist/Internal.hs
b/src/Text/Templating/Heist/Internal.hs
index b4cd56b..9256e6c 100644
--- a/src/Text/Templating/Heist/Internal.hs
+++ b/src/Text/Templating/Heist/Internal.hs
@@ -232,7 +232,8 @@ lookupTemplate nameStr ts =
where (name:p) = case splitTemplatePath nameStr of
[] -> [""]
ps -> ps
- path = p ++ (_curContext ts)
+ ctx = if B.isPrefixOf "/" nameStr then [] else _curContext ts
+ path = p ++ ctx
f = if '/' `BC.elem` nameStr
then singleLookup
else traversePath
diff --git a/src/Text/Templating/Heist/Splices/Apply.hs
b/src/Text/Templating/Heist/Splices/Apply.hs
index 33a9d79..baaa387 100644
--- a/src/Text/Templating/Heist/Splices/Apply.hs
+++ b/src/Text/Templating/Heist/Splices/Apply.hs
@@ -46,11 +46,7 @@ applyNodes nodes template = do
(\(t,ctx) -> do
addDoctype $ maybeToList $ X.docType t
rawApply (X.docContent t) ctx nodes)
- (lookupTemplate (T.encodeUtf8 template)
- (st {_curContext = nextCtx template st}))
- where nextCtx name st
- | T.isPrefixOf "/" name = []
- | otherwise = _curContext st
+ (lookupTemplate (T.encodeUtf8 template) st)
------------------------------------------------------------------------------
diff --git a/test/.ghci b/test/.ghci
index 21d35b1..ca79ef2 100644
--- a/test/.ghci
+++ b/test/.ghci
@@ -2,5 +2,4 @@
:set -Wall
:set -i../src
:set -isuite
-:set -hide-package mtl
:set -hide-package MonadCatchIO-mtl
diff --git a/test/suite/Text/Templating/Heist/Tests.hs
b/test/suite/Text/Templating/Heist/Tests.hs
index a260a5f..f8a5734 100644
--- a/test/suite/Text/Templating/Heist/Tests.hs
+++ b/test/suite/Text/Templating/Heist/Tests.hs
@@ -1,6 +1,7 @@
{-# LANGUAGE GeneralizedNewtypeDeriving #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TypeSynonymInstances #-}
+{-# LANGUAGE NoMonomorphismRestriction #-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
module Text.Templating.Heist.Tests
@@ -62,6 +63,7 @@ tests = [ testProperty "heist/simpleBind"
simpleBindTest
, testCase "heist/markdownText" markdownTextTest
, testCase "heist/apply" applyTest
, testCase "heist/ignore" ignoreTest
+ , testCase "heist/lookupTemplateContext" lookupTemplateTest
]
@@ -298,6 +300,19 @@ ignoreTest = do
H.assertEqual "<ignore> tag" [] res
+--localTSTest :: H.Assertion
+--localTSTest = do
+-- let es = (emptyTemplateState ".") :: TemplateState IO
+
+lookupTemplateTest = do
+ ts <- loadTS "templates"
+ let k = do
+ setContext ["foo"]
+ getsTS $ lookupTemplate "/user/menu"
+ res <- runTemplateMonad k (X.TextNode "") ts
+ H.assertBool "lookup context test" $ isJust $ fst res
+
+
------------------------------------------------------------------------------
-- Utility functions
commit b279cabc7e44ba4aca71023e18885edb6e087f87
Author: Mighty Byte <[email protected]>
Date: Sun Apr 10 09:50:36 2011 -0400
Use first function from Control.Arrow.
diff --git a/src/Text/Templating/Heist/Types.hs
b/src/Text/Templating/Heist/Types.hs
index 62689e6..9aa698e 100644
--- a/src/Text/Templating/Heist/Types.hs
+++ b/src/Text/Templating/Heist/Types.hs
@@ -22,6 +22,7 @@ module Text.Templating.Heist.Types where
------------------------------------------------------------------------------
import Control.Applicative
+import Control.Arrow
import Control.Monad.Cont
import Control.Monad.Error
import Control.Monad.Reader
@@ -153,11 +154,6 @@ evalTemplateMonad m r s = do
(a, _) <- runTemplateMonad m r s
return a
-------------------------------------------------------------------------------
--- | Helper function for the functor instance
-first :: (a -> b) -> (a, c) -> (b, c)
-first f (a,b) = (f a, b)
-
------------------------------------------------------------------------------
-- | Functor instance
-----------------------------------------------------------------------
hooks/post-receive
--
heist
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap