Skip to content

Commit

Permalink
hsx: Allow { ...values} spread, with a space in front
Browse files Browse the repository at this point in the history
Fixes #1588
  • Loading branch information
mpscholten committed Jan 22, 2023
1 parent 77ed18b commit 64f2f31
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Test/HSX/ParserSpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ tests = do
-- 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 parse spread values with a space" do
-- See https://github.com/digitallyinduced/ihp/issues/1588
let p = parseHsx position extensions "<div { ...variables }/>"
tshow p `shouldBe` "Right (Children [Node \"div\" [SpreadAttributes (VarE variables)] [] False])"

it "should accept underscores in data attributes" do
let p = parseHsx position extensions "<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 @@ -155,7 +155,7 @@ isStaticAttribute _ = False

hsxSplicedAttributes :: Parser Attribute
hsxSplicedAttributes = do
(pos, name) <- between (string "{...") (string "}") do
(pos, name) <- between (do char '{'; optional space; string "...") (string "}") do
pos <- getSourcePos
code <- takeWhile1P Nothing (\c -> c /= '}')
pure (pos, code)
Expand Down

0 comments on commit 64f2f31

Please sign in to comment.