packages feed

heist 0.1.1 → 0.1.2

raw patch · 14 files changed

+57/−34 lines, 14 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

Files

README.SNAP.md view
@@ -1,5 +1,5 @@-Snap Framework 0.1.1---------------------+Snap Framework+--------------  This is the first developer prerelease of the Snap framework.  Snap is a simple and fast web development framework and server written in Haskell. For more
README.md view
@@ -1,5 +1,5 @@-Heist 0.1.1------------+Heist+-----  Heist, part of the Snap Framework (http://www.snapframework.com/), is a Haskell library for xhtml templating. FIXME: more description here
examples/ex01/home.tpl view
@@ -4,7 +4,7 @@   </head>   <body>     <h1>Home Page</h1>-    <snap:apply template="ex01/nav"/>+    <apply template="ex01/nav"/>     <p>Welcome to our home page.</p>   </body> </html>
examples/ex02/home.tpl view
@@ -1,4 +1,4 @@-<snap:apply template="ex02/default">+<apply template="ex02/default">   <h1>Home Page</h1>   <p>Welcome to XYZ Inc</p>-</snap:apply>+</apply>
examples/ex03/home.tpl view
@@ -1,9 +1,9 @@-<snap:apply template="ex03/default">-  <snap:bind tag="header">+<apply template="ex03/default">+  <bind tag="header">     <h1>XYZ Inc.</h1>-  </snap:bind>-  <snap:bind tag="main">+  </bind>+  <bind tag="main">     <h1>Home Page</h1>     <p>Welcome to XYZ Inc</p>-  </snap:bind>-</snap:apply>+  </bind>+</apply>
examples/test01.tpl view
@@ -1,1 +1,1 @@-<root><snap:bind tag="foo"><snap:bind tag="foo">bar</snap:bind></snap:bind><foo/><foo/></root>+<root><bind tag="foo"><bind tag="foo">bar</bind></bind><foo/><foo/></root>
examples/test02.tpl view
@@ -1,4 +1,4 @@-<root><snap:bind tag="foo">***</snap:bind>+<root><bind tag="foo">***</bind> <foo/> This is a test <foo/> of the emergency broadcasting system. <foo/>
extra/haddock.css view
@@ -50,7 +50,7 @@ BODY {    -moz-border-radius:5px;   -webkit-border-radius:5px;-  width: 90ex;+  width: 50em;   margin: 2em auto;   padding: 0;   background-color: #ffffff;
heist.cabal view
@@ -1,5 +1,5 @@ name:           heist-version:        0.1.1+version:        0.1.2 synopsis:       An xhtml templating system license:        BSD3 license-file:   LICENSE@@ -108,4 +108,4 @@  source-repository head   type:     git-  location: http://git.snapframework.com/heist+  location: http://git.snapframework.com/heist.git
src/Text/Templating/Heist.hs view
@@ -132,17 +132,6 @@                                    return return return  ---------------------------------------------------------------------------------- | Reloads the templates from disk and renders the specified--- template.  (Old convenience code.)---renderTemplate' :: FilePath -> ByteString -> IO (Maybe ByteString)---renderTemplate' baseDir name = do---    etm <- loadTemplates baseDir emptyTemplateState---    let ts = either (const emptyTemplateState) id etm---    ns <- runTemplate ts name---    return $ (Just . formatList') =<< ns-- -- $hookDoc -- Heist hooks allow you to modify templates when they are loaded and before -- and after they are run.  Every time you call one of the addAbcHook
src/Text/Templating/Heist/Internal.hs view
@@ -187,9 +187,15 @@   --------------------------------------------------------------------------------- | Converts a path into an array of the elements in reverse order.+-- | Converts a path into an array of the elements in reverse order.  If the+-- path is absolute, we need to remove the leading slash so the split doesn't+-- leave @\"\"@ as the last element of the TPath.+--+-- FIXME @\"..\"@ currently doesn't work in paths, the solution is non-trivial splitPaths :: ByteString -> TPath-splitPaths = reverse . B.split '/'+splitPaths p = if B.null p then [] else (reverse $ B.split '/' path)+  where+    path = if B.head p == '/' then B.tail p else p   ------------------------------------------------------------------------------@@ -445,13 +451,17 @@ ------------------------------------------------------------------------------ -- | Loads a template with the specified path and filename.  The -- template is only loaded if it has a ".tpl" extension.-loadTemplate :: String -> String -> IO [Either String (TPath, Template)] --TemplateMap-loadTemplate path fname+loadTemplate :: String -- ^ path of the template root+             -> String -- ^ full file path (includes the template root)+             -> IO [Either String (TPath, Template)] --TemplateMap+loadTemplate templateRoot fname     | ".tpl" `isSuffixOf` fname = do         c <- getDoc fname         return [fmap (\t -> (splitPaths $ B.pack tName, t)) c]     | otherwise = return []-  where tName = drop ((length path)+1) $+  where -- tName is path relative to the template root directory+        tName = drop ((length templateRoot)+1) $+                -- We're only dropping the template root, not the whole path                 take ((length fname) - 4) fname  
test/suite/Text/Templating/Heist/Tests.hs view
@@ -1,6 +1,7 @@ {-# LANGUAGE OverloadedStrings, TypeSynonymInstances, GeneralizedNewtypeDeriving #-} module Text.Templating.Heist.Tests   ( tests+  , quickRender   ) where  import           Test.Framework (Test)@@ -12,6 +13,7 @@  import           Control.Monad.State +import           Data.ByteString.Char8 (ByteString) import qualified Data.ByteString.Char8 as B import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.Map as Map@@ -89,7 +91,15 @@   f isNothing "abc/def/xyz"   f isJust "a"   f isJust "bar/a"+  f isJust "/bar/a" +-- dotdotTest :: H.Assertion+-- dotdotTest = do+--   ets <- loadT "templates"+--   let tm = either (error "Error loading templates") _templateMap ets+--   let ts = setTemplates tm emptyTemplateState :: TemplateState IO+--       f p n = H.assertBool ("loading template "++n) $ p $ lookupTemplate (B.pack n) ts+ identStartChar :: [Char] identStartChar = ['a'..'z'] identChar :: [Char]@@ -275,6 +285,17 @@   let correct = calcCorrect apply   result <- run $ calcResult apply   assert $ correct == result+++------------------------------------------------------------------------------+-- | Reloads the templates from disk and renders the specified+-- template.  (Old convenience code.)+quickRender :: FilePath -> ByteString -> IO (Maybe ByteString)+quickRender baseDir name = do+    etm <- loadTemplates baseDir emptyTemplateState+    let ts = either (const emptyTemplateState) id etm+    ns <- runTemplate ts name+    return $ (Just . formatList') =<< ns   {-
test/templates/user/admin/main.tpl view
@@ -1,4 +1,6 @@ <html> Admin Page <apply template="menu"/>+<apply template="../menu"/>+<apply template="../../a"/> </html>
test/templates/user/main.tpl view
@@ -1,4 +1,5 @@ <html> User Page <apply template="menu"/>+<apply template="admin/menu"/> </html>