From d29e4157f1647b06367c2e04c1cdea4c8175fd4c Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 5 Jan 2010 11:11:02 +0100 Subject: Added an havingExtension filter because it's handy. --- src/Text/Hakyll/File.hs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/Text/Hakyll') diff --git a/src/Text/Hakyll/File.hs b/src/Text/Hakyll/File.hs index 5f5e58b..c535b11 100644 --- a/src/Text/Hakyll/File.hs +++ b/src/Text/Hakyll/File.hs @@ -6,6 +6,7 @@ module Text.Hakyll.File , toURL , makeDirectories , getRecursiveContents + , havingExtension , isCacheValid , directory ) where @@ -47,6 +48,12 @@ getRecursiveContents topdir = do return (concat paths) where isProper = not . (== '.') . head +-- | A filter that takes all file names with a given extension. Prefix the +-- extension with a dot: +-- > havingExtension ".markdown" ["index.markdown", "style.css"] == ["index.markdown"] +havingExtension :: String -> [FilePath] -> [FilePath] +havingExtension extension = filter ((==) extension . takeExtension) + -- | Perform an IO action on every file in a given directory. directory :: (FilePath -> IO ()) -> FilePath -> IO () directory action dir = getRecursiveContents dir >>= mapM_ action -- cgit v1.2.3