summaryrefslogtreecommitdiff
path: root/src/Hakyll/Web/Template/List.hs
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2013-01-16 10:50:01 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2013-01-16 10:50:01 +0100
commit652ceb03f1185ad8d41e7a3b91f00e1064bdd4ba (patch)
treea269f96a06462531678263a0d678457f2b59af70 /src/Hakyll/Web/Template/List.hs
parente53ca6724c8f5715792ad6b269ede52f21eb606c (diff)
downloadhakyll-652ceb03f1185ad8d41e7a3b91f00e1064bdd4ba.tar.gz
Add applyJoinTemplateList, and a test for it
Diffstat (limited to 'src/Hakyll/Web/Template/List.hs')
-rw-r--r--src/Hakyll/Web/Template/List.hs21
1 files changed, 17 insertions, 4 deletions
diff --git a/src/Hakyll/Web/Template/List.hs b/src/Hakyll/Web/Template/List.hs
index e8da74f..6d2a341 100644
--- a/src/Hakyll/Web/Template/List.hs
+++ b/src/Hakyll/Web/Template/List.hs
@@ -9,13 +9,14 @@
-- * A sitemap
module Hakyll.Web.Template.List
( applyTemplateList
+ , applyJoinTemplateList
, chronological
, recentFirst
) where
--------------------------------------------------------------------------------
-import Data.List (sortBy)
+import Data.List (intersperse, sortBy)
import Data.Ord (comparing)
import System.FilePath (takeBaseName)
@@ -29,14 +30,26 @@ import Hakyll.Web.Template.Context
--------------------------------------------------------------------------------
--- | Set a field of a page to a listing of pages
+-- | Generate a string of a listing of pages, after applying a template to each
+-- page.
applyTemplateList :: Template
-> Context a
-> [Item a]
-> Compiler String
-applyTemplateList tpl context items = do
+applyTemplateList = applyJoinTemplateList ""
+
+
+--------------------------------------------------------------------------------
+-- | Join a listing of pages with a string in between, after applying a template
+-- to each page.
+applyJoinTemplateList :: String
+ -> Template
+ -> Context a
+ -> [Item a]
+ -> Compiler String
+applyJoinTemplateList delimiter tpl context items = do
items' <- mapM (applyTemplate tpl context) items
- return $ concat $ map itemBody items'
+ return $ concat $ intersperse delimiter $ map itemBody items'
--------------------------------------------------------------------------------