diff options
author | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-01-25 20:56:10 +0100 |
---|---|---|
committer | Jasper Van der Jeugt <jaspervdj@gmail.com> | 2011-01-25 20:56:10 +0100 |
commit | 6cecbb890f829e30e533e58287867981ca04d78a (patch) | |
tree | 7e45a69dab7110964575564e9fb12e8e9b65266f /src/Hakyll/Core | |
parent | 7ba1413ea99a8b7c683fedf94de3a3a764277b53 (diff) | |
download | hakyll-6cecbb890f829e30e533e58287867981ca04d78a.tar.gz |
Add `fromCaptureString` function
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r-- | src/Hakyll/Core/Identifier/Pattern.hs | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/src/Hakyll/Core/Identifier/Pattern.hs b/src/Hakyll/Core/Identifier/Pattern.hs index 0590387..7c88356 100644 --- a/src/Hakyll/Core/Identifier/Pattern.hs +++ b/src/Hakyll/Core/Identifier/Pattern.hs @@ -35,6 +35,7 @@ module Hakyll.Core.Identifier.Pattern , doesMatch , matches , fromCapture + , fromCaptureString , fromCaptures ) where @@ -122,9 +123,29 @@ match' (m : ms) (s : ss) = case m of -- | Create an identifier from a pattern by filling in the captures with a given -- string -- +-- Example: +-- +-- > fromCapture (parsePattern "tags/*") (parseIdentifier "foo") +-- +-- Result: +-- +-- > "tags/foo" +-- fromCapture :: Pattern -> Identifier -> Identifier fromCapture pattern = fromCaptures pattern . repeat +-- | Simplified version of 'fromCapture' which takes a 'String' instead of an +-- 'Identifier' +-- +-- > fromCaptureString (parsePattern "tags/*") "foo" +-- +-- Result: +-- +-- > "tags/foo" +-- +fromCaptureString :: Pattern -> String -> Identifier +fromCaptureString pattern = fromCapture pattern . parseIdentifier + -- | Create an identifier from a pattern by filling in the captures with the -- given list of strings -- |