From 28a30caef08ab786bfa8b75d75f155a4e62b7280 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 15 Feb 2011 22:39:20 +0100 Subject: defaultTemplateRead → templateCompiler MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Hakyll/Web.hs | 13 +------------ src/Hakyll/Web/Page.hs | 8 +++++--- src/Hakyll/Web/Template.hs | 17 +++++++++-------- 3 files changed, 15 insertions(+), 23 deletions(-) (limited to 'src') 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"] -- cgit v1.2.3