Skip to content

Commit

Permalink
Stopped 'contentHash' from unnecesarily consuming hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
terickson001 committed Dec 15, 2016
1 parent a117e66 commit a26cbb1
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions Text/Hamlet/Parse.hs
Expand Up @@ -246,7 +246,9 @@ parseLine set = do
cc [] = []
cc (ContentRaw a:ContentRaw b:c) = cc $ ContentRaw (a ++ b) : c
cc (a:b) = a : cc b
content' cr = contentHash <|> contentAt <|> contentCaret
content' cr = try (lookAhead (string "#{") >> contentHash)
<|> contentAt
<|> contentCaret
<|> contentUnder
<|> contentReg' cr
contentHash = do
Expand Down Expand Up @@ -281,13 +283,7 @@ parseLine set = do
tagCond = do
d <- between (char ':') (char ':') parseDeref
tagClass (Just d) <|> tagAttrib (Just d)
tagClass x = do
clazz <- char '.' >> tagAttribValue NotInQuotes
let hasHash (ContentRaw s) = any (== '#') s
hasHash _ = False
if any hasHash clazz
then fail $ "Invalid class: " ++ show clazz ++ ". Did you want a space between a class and an ID?"
else return (TagClass (x, clazz))
tagClass x = char '.' >> (TagClass . ((,)x)) <$> tagAttribValue NotInQuotes
tagAttrib cond = do
s <- many1 $ noneOf " \t=\r\n><"
v <- (char '=' >> Just <$> tagAttribValue NotInQuotesAttr) <|> return Nothing
Expand Down

0 comments on commit a26cbb1

Please sign in to comment.