From e687662ba0421729c4ab07c08744004c2ea1dd55 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Thu, 6 Jun 2013 10:21:18 +0200 Subject: teaserContext -> teaserField --- src/Hakyll/Core/Configuration.hs | 1 - src/Hakyll/Web/Template/Context.hs | 24 +++++++++++++----------- 2 files changed, 13 insertions(+), 12 deletions(-) (limited to 'src/Hakyll') diff --git a/src/Hakyll/Core/Configuration.hs b/src/Hakyll/Core/Configuration.hs index 790badc..a4bc90b 100644 --- a/src/Hakyll/Core/Configuration.hs +++ b/src/Hakyll/Core/Configuration.hs @@ -8,7 +8,6 @@ module Hakyll.Core.Configuration -------------------------------------------------------------------------------- -import Control.Monad (void) import Data.Default (Default (..)) import Data.List (isPrefixOf, isSuffixOf) import System.Directory (canonicalizePath) diff --git a/src/Hakyll/Web/Template/Context.hs b/src/Hakyll/Web/Template/Context.hs index 7b2d920..3fde93b 100644 --- a/src/Hakyll/Web/Template/Context.hs +++ b/src/Hakyll/Web/Template/Context.hs @@ -8,7 +8,6 @@ module Hakyll.Web.Template.Context , listField , defaultContext - , teaserContext , bodyField , metadataField , urlField @@ -19,6 +18,7 @@ module Hakyll.Web.Template.Context , getItemUTC , modificationTimeField , modificationTimeFieldWith + , teaserField , missingField ) where @@ -96,16 +96,6 @@ defaultContext = missingField --------------------------------------------------------------------------------- --- | A context with "teaser" key which contain a teaser of the item. --- The item is loaded from the given snapshot (which should be saved --- in the user code before any templates are applied). -teaserContext :: Snapshot -> Context String -teaserContext snapshot = field "teaser" $ \item -> - (needlePrefix teaserSeparator . itemBody) <$> - loadSnapshot (itemIdentifier item) snapshot - - -------------------------------------------------------------------------------- teaserSeparator :: String teaserSeparator = "" @@ -245,6 +235,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do return $ formatTime locale fmt mtime +-------------------------------------------------------------------------------- +-- | A context with "teaser" key which contain a teaser of the item. +-- The item is loaded from the given snapshot (which should be saved +-- in the user code before any templates are applied). +teaserField :: String -- ^ Key to use + -> Snapshot -- ^ Snapshot to load + -> Context String -- ^ Resulting context +teaserField key snapshot = field key $ \item -> + (needlePrefix teaserSeparator . itemBody) <$> + loadSnapshot (itemIdentifier item) snapshot + + -------------------------------------------------------------------------------- missingField :: Context a missingField = Context $ \k i -> fail $ -- cgit v1.2.3