Skip to content

Commit

Permalink
HSX: Support underscores in data attribute names
Browse files Browse the repository at this point in the history
  • Loading branch information
mpscholten committed May 26, 2022
1 parent 1ff977d commit 5e772f6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
4 changes: 4 additions & 0 deletions Test/HSX/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,7 @@ tests = do
let p = parseHsx position "<div {...variables}/>"
-- We cannot easily construct the @VarE variables@ expression, therefore we use show here for comparison
tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"

it "should accept underscores in data attributes" do
let p = parseHsx position "<div data-client_id=\"test\"/>"
p `shouldBe` (Right (Children [Node "div" [StaticAttribute "data-client_id" (TextValue "test")] [] False]))
2 changes: 1 addition & 1 deletion ihp-hsx/IHP/HSX/Parser.hs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ hsxAttributeName = do
|| "hx-" `Text.isPrefixOf` name
|| name `Set.member` attributes

rawAttribute = takeWhile1P Nothing (\c -> Char.isAlphaNum c || c == '-')
rawAttribute = takeWhile1P Nothing (\c -> Char.isAlphaNum c || c == '-' || c == '_')


hsxQuotedValue :: Parser AttributeValue
Expand Down

0 comments on commit 5e772f6

Please sign in to comment.