@@ -35,6 +35,7 @@ module Hakyll.Core.Identifier.Pattern
3535 , doesMatch
3636 , matches
3737 , fromCapture
38+ , fromCaptureString
3839 , fromCaptures
3940 ) where
4041
@@ -122,9 +123,29 @@ match' (m : ms) (s : ss) = case m of
122123-- | Create an identifier from a pattern by filling in the captures with a given
123124-- string
124125--
126+-- Example:
127+--
128+-- > fromCapture (parsePattern "tags/*") (parseIdentifier "foo")
129+--
130+-- Result:
131+--
132+-- > "tags/foo"
133+--
125134fromCapture :: Pattern -> Identifier -> Identifier
126135fromCapture pattern = fromCaptures pattern . repeat
127136
137+-- | Simplified version of 'fromCapture' which takes a 'String' instead of an
138+-- 'Identifier'
139+--
140+-- > fromCaptureString (parsePattern "tags/*") "foo"
141+--
142+-- Result:
143+--
144+-- > "tags/foo"
145+--
146+fromCaptureString :: Pattern -> String -> Identifier
147+fromCaptureString pattern = fromCapture pattern . parseIdentifier
148+
128149-- | Create an identifier from a pattern by filling in the captures with the
129150-- given list of strings
130151--