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  8237880579b857632c369b65fefb13f2b93c3644 (commit)
      from  4d023be4bdeb211cdebb155dcbf11f7e49016063 (commit)


Summary of changes:
 src/Text/Templating/Heist/Internal.hs |   25 +++++++++++++++++++------
 1 files changed, 19 insertions(+), 6 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 8237880579b857632c369b65fefb13f2b93c3644
Author: Jacob Stanley <[email protected]>
Date:   Mon May 31 04:15:07 2010 +0800

    Windows: Fixed loading of templates in subdirectories

diff --git a/src/Text/Templating/Heist/Internal.hs 
b/src/Text/Templating/Heist/Internal.hs
index 0a65b28..614136c 100644
--- a/src/Text/Templating/Heist/Internal.hs
+++ b/src/Text/Templating/Heist/Internal.hs
@@ -19,6 +19,7 @@ import           Data.Map (Map)
 import           Data.Typeable
 import           Prelude hiding (catch)
 import           System.Directory.Tree hiding (name)
+import           System.FilePath
 import           Text.XML.Expat.Format
 import qualified Text.XML.Expat.Tree as X
 
@@ -196,10 +197,22 @@ lookupSplice nm ts = Map.lookup nm $ _spliceMap ts
 -- leave @\"\"@ as the last element of the TPath.
 --
 -- FIXME @\"..\"@ currently doesn't work in paths, the solution is non-trivial
-splitPaths :: ByteString -> TPath
-splitPaths p = if B.null p then [] else (reverse $ B.split '/' path)
+splitPathWith :: Char -> ByteString -> TPath
+splitPathWith s p = if B.null p then [] else (reverse $ B.split s path)
   where
-    path = if B.head p == '/' then B.tail p else p
+    path = if B.head p == s then B.tail p else p
+
+-- | Converts a path into an array of the elements in reverse order using the
+-- path separator of the local operating system. See 'splitPathWith' for more
+-- details.
+splitLocalPath :: ByteString -> TPath
+splitLocalPath = splitPathWith pathSeparator
+
+-- | Converts a path into an array of the elements in reverse order using a
+-- forward slash (/) as the path separator. See 'splitPathWith' for more
+-- details.
+splitTemplatePath :: ByteString -> TPath
+splitTemplatePath = splitPathWith '/'
 
 
 ------------------------------------------------------------------------------
@@ -232,7 +245,7 @@ lookupTemplate :: Monad m =>
                -> Maybe (Template, TPath)
 lookupTemplate nameStr ts = 
     f (_templateMap ts) path name
-  where (name:p) = case splitPaths nameStr of
+  where (name:p) = case splitTemplatePath nameStr of
                        [] -> [""]
                        ps -> ps
         path = p ++ (_curContext ts)
@@ -265,7 +278,7 @@ addTemplate :: Monad m =>
             -> Template
             -> TemplateState m
             -> TemplateState m
-addTemplate n t st = insertTemplate (splitPaths n) t st
+addTemplate n t st = insertTemplate (splitTemplatePath n) t st
 
 
 ------------------------------------------------------------------------------
@@ -475,7 +488,7 @@ loadTemplate :: String -- ^ path of the template root
 loadTemplate templateRoot fname
     | ".tpl" `isSuffixOf` fname = do
         c <- getDoc fname
-        return [fmap (\t -> (splitPaths $ B.pack tName, t)) c]
+        return [fmap (\t -> (splitLocalPath $ B.pack tName, t)) c]
     | otherwise = return []
   where -- tName is path relative to the template root directory
         tName = drop ((length templateRoot)+1) $
-----------------------------------------------------------------------


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

Reply via email to