packages feed

hakyll 4.3.2.0 → 4.3.3.0

raw patch · 6 files changed

+17/−2 lines, 6 filesPVP ok

version bump matches the API change (PVP)

API changes (from Hackage documentation)

+ Hakyll.Web.Template.Context: functionField :: String -> ([String] -> Item a -> Compiler String) -> Context a

Files

hakyll.cabal view
@@ -1,5 +1,5 @@ Name:    hakyll-Version: 4.3.2.0+Version: 4.3.3.0  Synopsis: A static website compiler library Description:
src/Hakyll/Web/Template/Context.hs view
@@ -6,6 +6,7 @@     , field     , constField     , listField+    , functionField     , mapContext      , defaultContext@@ -84,6 +85,15 @@ -------------------------------------------------------------------------------- listField :: String -> Context a -> Compiler [Item a] -> Context b listField key c xs = field' key $ \_ -> fmap (ListField c) xs+++--------------------------------------------------------------------------------+functionField :: String -> ([String] -> Item a -> Compiler String) -> Context a+functionField name value = Context $ \k i -> case words k of+    []              -> empty+    (n : args)+        | n == name -> StringField <$> value args i+        | otherwise -> empty   --------------------------------------------------------------------------------
src/Hakyll/Web/Template/Read.hs view
@@ -21,7 +21,7 @@ readTemplate :: String -> Template readTemplate input = case parse template "" input of     Left err -> error $ "Cannot parse template: " ++ show err-    Right t -> t+    Right t  -> t   --------------------------------------------------------------------------------
tests/Hakyll/Web/Template/Tests.hs view
@@ -58,6 +58,7 @@         n1 <- makeItem "Jan"         n2 <- makeItem "Piet"         return [n1, n2]+    , functionField "rev" $ \args _ -> return $ unwords $ map reverse args     ]   where 
tests/data/template.html view
@@ -1,6 +1,8 @@ <div>     I'm so rich I have $$3. +    $rev foo$+     $if(body)$     I have body     $else$
tests/data/template.html.out view
@@ -1,6 +1,8 @@ <div>     I'm so rich I have $3. +    oof+          I have body