Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: bool constants can be followed by > #119

Merged
merged 1 commit into from
Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions parser/v2/elementparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,8 @@ var boolConstantAttributeParser = parse.Func(func(pi *parse.Input) (attr BoolCon
pi.Seek(start)
return attr, false, nil
}
if !(next == " " || next == "\t" || next == "\n" || next == "/") {
err = parse.Error(fmt.Sprintf("boolConstantAttributeParser: expected attribute name to end with space, newline or '/>', but got %q", next), pi.Position())
if !(next == " " || next == "\t" || next == "\n" || next == "/" || next == ">") {
err = parse.Error(fmt.Sprintf("boolConstantAttributeParser: expected attribute name to end with space, newline, '/>' or '>', but got %q", next), pi.Position())
return attr, false, err
}

Expand Down
15 changes: 14 additions & 1 deletion parser/v2/elementparser_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -266,6 +266,19 @@ if test {
Value: "",
},
},
{
name: "bool constant attribute",
input: `<div data>`,
parser: StripType(elementOpenTagParser),
expected: elementOpenTag{
Name: "div",
Attributes: []Attribute{
BoolConstantAttribute{
Name: "data",
},
},
},
},
{
name: "attribute containing escaped text",
input: ` href="&lt;&quot;&gt;"`,
Expand Down Expand Up @@ -766,7 +779,7 @@ func TestElementParser(t *testing.T) {
},
},
{
name: "element: inputs can contain class attributes",
name: "element: inputs can contain class attributes",
input: `<input type="email" id="email" name="email" class={ "a", "b", "c", templ.KV("c", false)} placeholder="your@email.com" autocomplete="off"/>`,
expected: Element{
Name: "input",
Expand Down