@@ -1,8 +1,7 @@
11-- | Module containing rendering functions. All these functions are used to
22-- render files to the @_site@ directory.
33module Text.Hakyll.Render
4− ( depends
5− , render
4+ ( render
65 , renderWith
76 , renderAndConcat
87 , renderAndConcatWith
@@ -12,7 +11,6 @@ module Text.Hakyll.Render
1211 , css
1312 ) where
1413
15−import Control.Monad (unless)
1614import Control.Arrow ((>>>))
1715import Control.Monad.Reader (liftIO)
1816import System.Directory (copyFile)
@@ -27,16 +25,6 @@ import Text.Hakyll.Internal.CompressCss
2725import Text.Hakyll.Internal.Render
2826import Text.Hakyll.Internal.Template (readTemplate)
2927
30−-- | Execute an IO action only when the cache is invalid.
31−depends :: FilePath -- ^ File to be rendered or created.
32− -> [FilePath] -- ^ Files the render depends on.
33− -> Hakyll () -- ^ Action to execute when the file is out of date.
34− -> Hakyll ()
35−depends file dependencies action = do
36− destination <- toDestination file
37− valid <- isFileMoreRecent destination dependencies
38− unless valid action
39−
4028-- | Render to a Page.
4129render :: FilePath -- ^ Template to use for rendering.
4230 -> RenderAction Context Context -- ^ The render computation.
@@ -113,7 +101,7 @@ renderChainWith :: ContextManipulation
113101 -> RenderAction () Context
114102 -> Hakyll ()
115103renderChainWith manipulation templatePaths initial =
116− runRenderAction renderChainWith'
104+ runRenderActionIfNeeded renderChainWith'
117105 where
118106 renderChainWith' :: RenderAction () ()
119107 renderChainWith' = initial >>> manipulationAction >>> chain' >>> writePage
@@ -125,30 +113,18 @@ renderChainWith manipulation templatePaths initial =
125113-- | Mark a certain file as static, so it will just be copied when the site is
126114-- generated.
127115static :: FilePath -> Hakyll ()
128−static source = runRenderAction static'
116+static source = runRenderActionIfNeeded static'
129117 where
130− static' = RenderAction
131− { actionDependencies = [source]
132− , actionUrl = Just $ return source
133− , actionFunction = actionFunction'
134− }
135−
136− actionFunction' _ = do
118+ static' = createFileRenderAction source $ do
137119 destination <- toDestination source
138120 makeDirectories destination
139121 liftIO $ copyFile source destination
140122
141123-- | Render a css file, compressing it.
142124css :: FilePath -> Hakyll ()
143−css source = runRenderAction css'
125+css source = runRenderActionIfNeeded css'
144126 where
145− css' = RenderAction
146− { actionDependencies = [source]
147− , actionUrl = Just $ return source
148− , actionFunction = actionFunction'
149− }
150−
151− actionFunction' _ = do
127+ css' = createFileRenderAction source $ do
152128 contents <- liftIO $ readFile source
153129 destination <- toDestination source
154130 makeDirectories destination