diff --git a/yesod-test/Yesod/Test.hs b/yesod-test/Yesod/Test.hs index e736ddd3..21fae9c3 100644 --- a/yesod-test/Yesod/Test.hs +++ b/yesod-test/Yesod/Test.hs @@ -564,23 +564,23 @@ nameFromLabel label = do name:_ -> return name _ -> failure $ "More than one label contained " <> label --- This looks up the name of a field based on the contents of the label pointing to it (exact). -nameFromLabelExact :: T.Text -> RequestBuilder site T.Text -nameFromLabelExact label = do +-- This looks up the name of a field based on the contents of the label pointing to it. +genericNameFromLabel :: (T.Text -> T.Text -> Bool) -> T.Text -> RequestBuilder site T.Text +genericNameFromLabel match label = do mres <- fmap rbdResponse ST.get res <- case mres of - Nothing -> failure "nameFromLabel: No response available" + Nothing -> failure "genericNameFromLabel: No response available" Just res -> return res let body = simpleBody res mlabel = parseHTML body $// C.element "label" - >=> contentIs label + >=> contentMatches label mfor = mlabel >>= attribute "for" - contentIs x c - | x == T.concat (c $// content) = [c] + contentMatches x c + | x `match` T.concat (c $// content) = [c] | otherwise = [] case mfor of @@ -632,11 +632,12 @@ nameFromLabelExact label = do -- >
-- > -- >
-byLabel :: T.Text -- ^ The text contained in the @\