on master help sign in
Add listFieldWith
76cfb53Jasper Van der Jeugt
src/Hakyll/Web/Template/Context.hs+8−1
@@ -6,6 +6,7 @@ module Hakyll.Web.Template.Context
6 , field
6 , field
7 , constField
7 , constField
8 , listField
8 , listField
9+ , listFieldWith
9 , functionField
10 , functionField
10 , mapContext
11 , mapContext
11
12
@@ -104,7 +105,13 @@ constField key = field key . const . return
104
105
105--------------------------------------------------------------------------------
106--------------------------------------------------------------------------------
106listField :: String -> Context a -> Compiler [Item a] -> Context b
107listField :: String -> Context a -> Compiler [Item a] -> Context b
108+listField key c xs = listFieldWith key c (const xs)
109+
110+
111+--------------------------------------------------------------------------------
112+listFieldWith
113+ :: String -> Context a -> (Item b -> Compiler [Item a]) -> Context b
107−listField key c xs = field' key $ \_ -> fmap (ListField c) xs
114+listFieldWith key c f = field' key $ fmap (ListField c) . f
108
115
109
116
110--------------------------------------------------------------------------------
117--------------------------------------------------------------------------------