diff options
author | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-06-06 10:21:18 +0200 |
---|---|---|
committer | Jasper Van der Jeugt <m@jaspervdj.be> | 2013-06-06 10:21:18 +0200 |
commit | e687662ba0421729c4ab07c08744004c2ea1dd55 (patch) | |
tree | c58dca23fe638840d428dac2f5e02fb02c37e948 /src/Hakyll/Web | |
parent | fd917217ae218d7369a84c0b0dcdd9cfa937ca2a (diff) | |
download | hakyll-e687662ba0421729c4ab07c08744004c2ea1dd55.tar.gz |
teaserContext -> teaserField
Diffstat (limited to 'src/Hakyll/Web')
-rw-r--r-- | src/Hakyll/Web/Template/Context.hs | 24 |
1 files changed, 13 insertions, 11 deletions
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 @@ -97,16 +97,6 @@ defaultContext = -------------------------------------------------------------------------------- --- | 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 = "<!--more-->" @@ -246,6 +236,18 @@ modificationTimeFieldWith locale key fmt = field key $ \i -> do -------------------------------------------------------------------------------- +-- | 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 $ "Missing field $" ++ k ++ "$ in context for item " ++ |