From c1b814baab265d25d07c8de27526ecfa76d994bb Mon Sep 17 00:00:00 2001 From: Laurent Rene de Cotret Date: Tue, 29 Oct 2024 12:14:26 -0400 Subject: [PATCH] Cleanup following #1044 --- CHANGELOG.md | 3 ++- hakyll.cabal | 2 +- lib/Hakyll/Web/Template/Context.hs | 18 ++++++++++++------ 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9ed21444..aacb7003 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,10 +4,11 @@ title: Releases # Releases -## Unreleased +## Hakyll 4.16.4.0 (unreleased) - Fixed an issue where compressing CSS with `clamp` expressions would result in invalid CSS (#1021) (contribution by Laurent P. René de Cotret) +- Added `boolFieldM` (#1044) (contribution by 0xd34df00d) ## Hakyll 4.16.3.0 (2024-10-24) diff --git a/hakyll.cabal b/hakyll.cabal index 5a8de94f..b6938cab 100644 --- a/hakyll.cabal +++ b/hakyll.cabal @@ -1,5 +1,5 @@ Name: hakyll -Version: 4.16.3.0 +Version: 4.16.4.0 Synopsis: A static website compiler library Description: diff --git a/lib/Hakyll/Web/Template/Context.hs b/lib/Hakyll/Web/Template/Context.hs index 8bd5c6b3..abede215 100644 --- a/lib/Hakyll/Web/Template/Context.hs +++ b/lib/Hakyll/Web/Template/Context.hs @@ -145,16 +145,22 @@ field key value = field' key (fmap StringField . value) -- | Creates a 'field' to use with the @$if()$@ template macro. -- Attempting to substitute the field into the template will cause an error. boolField - :: String - -> (Item a -> Bool) + :: String -- ^ Key + -> (Item a -> Bool) -- ^ Extract value from an @'Item' a@ -> Context a boolField name f = boolFieldM name (pure . f) --- | Creates a 'field' to use with the @$if()$@ template macro, in the 'Compiler' monad. --- Attempting to substitute the field into the template will cause an error. + +-------------------------------------------------------------------------------- +-- | Creates a 'field' to use with the @$if()$@ template macro, in the +-- 'Compiler' monad. Attempting to substitute the field into the template +-- will cause an error. +-- +-- @since 4.16.4.0 boolFieldM - :: String - -> (Item a -> Compiler Bool) + :: String -- ^ Key + -> (Item a -> Compiler Bool) -- ^ Extract value from an @'Item' a@ + -- from within the 'Compiler' monad -> Context a boolFieldM name f = field' name (\i -> do b <- f i