summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-15 22:39:20 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-02-15 22:40:16 +0100
commit28a30caef08ab786bfa8b75d75f155a4e62b7280 (patch)
tree4a17678d817c7910d21be6c5e5fbdfc1d341fbe8
parentbc4fef81b7143d3b2035f3bd28fe89bea8dbc30d (diff)
downloadhakyll-28a30caef08ab786bfa8b75d75f155a4e62b7280.tar.gz
defaultTemplateRead → templateCompiler
-rw-r--r--src/Hakyll/Web.hs13
-rw-r--r--src/Hakyll/Web/Page.hs8
-rw-r--r--src/Hakyll/Web/Template.hs17
3 files changed, 15 insertions, 23 deletions
diff --git a/src/Hakyll/Web.hs b/src/Hakyll/Web.hs
index 72b22dd..ec05afb 100644
--- a/src/Hakyll/Web.hs
+++ b/src/Hakyll/Web.hs
@@ -1,16 +1,12 @@
-- | Module exporting commonly used web-related functions
--
module Hakyll.Web
- ( defaultTemplateRead
- , defaultTemplateReadWith
- , defaultCopyFile
+ ( defaultCopyFile
, defaultApplyTemplate
) where
import Control.Arrow ((>>^))
-import Text.Hamlet (HamletSettings)
-
import Hakyll.Core.Compiler
import Hakyll.Core.Writable
import Hakyll.Core.Identifier
@@ -18,13 +14,6 @@ import Hakyll.Core.ResourceProvider
import Hakyll.Web.Page
import Hakyll.Web.Template
-defaultTemplateRead :: Compiler Resource Template
-defaultTemplateRead = cached "Hakyll.Web.defaultTemplateRead" $ templateRead
-
-defaultTemplateReadWith :: HamletSettings -> Compiler Resource Template
-defaultTemplateReadWith settings = cached "Hakyll.Web.defaultTemplateReadWith" $
- templateReadWith settings
-
defaultCopyFile :: Compiler Resource CopyFile
defaultCopyFile = getIdentifier >>^ CopyFile . toFilePath
diff --git a/src/Hakyll/Web/Page.hs b/src/Hakyll/Web/Page.hs
index 30578e9..c61008c 100644
--- a/src/Hakyll/Web/Page.hs
+++ b/src/Hakyll/Web/Page.hs
@@ -52,7 +52,7 @@ module Hakyll.Web.Page
, fromMap
, toMap
, readPageCompiler
- , defaultPageCompiler
+ , pageCompiler
, addDefaultFields
, sortByBaseName
) where
@@ -97,8 +97,10 @@ toMap (Page m b) = M.insert "body" b m
readPageCompiler :: Compiler Resource (Page String)
readPageCompiler = getResourceString >>^ readPage
-defaultPageCompiler :: Compiler Resource (Page String)
-defaultPageCompiler = cached "Hakyll.Web.Page.defaultPageCompiler" $
+-- | Read a page, add default fields, substitute fields and render using pandoc
+--
+pageCompiler :: Compiler Resource (Page String)
+pageCompiler = cached "Hakyll.Web.Page.pageCompiler" $
readPageCompiler >>> addDefaultFields >>> arr applySelf >>> pageRenderPandoc
-- | Add a number of default metadata fields to a page. These fields include:
diff --git a/src/Hakyll/Web/Template.hs b/src/Hakyll/Web/Template.hs
index 70b689a..1a399b3 100644
--- a/src/Hakyll/Web/Template.hs
+++ b/src/Hakyll/Web/Template.hs
@@ -45,8 +45,8 @@ module Hakyll.Web.Template
( Template
, applyTemplate
, applySelf
- , templateRead
- , templateReadWith
+ , templateCompiler
+ , templateCompilerWith
) where
import Control.Arrow
@@ -86,14 +86,15 @@ applySelf page = applyTemplate (readTemplate $ pageBody page) page
-- @.hml@ or @.hamlet@, it will be considered as a Hamlet template, and parsed
-- as such.
--
-templateRead :: Compiler Resource Template
-templateRead = templateReadWith defaultHamletSettings
+templateCompiler :: Compiler Resource Template
+templateCompiler = templateCompilerWith defaultHamletSettings
--- | Version of 'templateRead' that enables custom settings.
+-- | Version of 'templateCompiler' that enables custom settings.
--
-templateReadWith :: HamletSettings -> Compiler Resource Template
-templateReadWith settings =
- getIdentifier &&& getResourceString >>^ uncurry read'
+templateCompilerWith :: HamletSettings -> Compiler Resource Template
+templateCompilerWith settings =
+ cached "Hakyll.Web.Template.templateCompilerWith" $
+ getIdentifier &&& getResourceString >>^ uncurry read'
where
read' identifier string =
if takeExtension (toFilePath identifier) `elem` [".hml", ".hamlet"]