diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-05 11:11:02 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2010-01-05 11:11:02 +0100 |
commit | d29e4157f1647b06367c2e04c1cdea4c8175fd4c (patch) | |
tree | 0fe5f0b132438a7c3a125f2143fdad9df56019f1 /src | |
parent | dbb9a0e1946fab03714ce52e605d6c1a5322aad6 (diff) | |
download | hakyll-d29e4157f1647b06367c2e04c1cdea4c8175fd4c.tar.gz |
Added an havingExtension filter because it's handy.
Diffstat (limited to 'src')
-rw-r--r-- | src/Text/Hakyll/File.hs | 7 |
1 files changed, 7 insertions, 0 deletions
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 |