summaryrefslogtreecommitdiff
path: root/src/Hakyll/Core
diff options
context:
space:
mode:
authorJasper Van der Jeugt <jaspervdj@gmail.com>2011-01-25 20:56:10 +0100
committerJasper Van der Jeugt <jaspervdj@gmail.com>2011-01-25 20:56:10 +0100
commit6cecbb890f829e30e533e58287867981ca04d78a (patch)
tree7e45a69dab7110964575564e9fb12e8e9b65266f /src/Hakyll/Core
parent7ba1413ea99a8b7c683fedf94de3a3a764277b53 (diff)
downloadhakyll-6cecbb890f829e30e533e58287867981ca04d78a.tar.gz
Add `fromCaptureString` function
Diffstat (limited to 'src/Hakyll/Core')
-rw-r--r--src/Hakyll/Core/Identifier/Pattern.hs21
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
--