Skip to content

Commit

Permalink
refactor: minor typos, capitlisation
Browse files Browse the repository at this point in the history
  • Loading branch information
a-h committed Sep 27, 2023
1 parent 0244fef commit 4deabea
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
6 changes: 3 additions & 3 deletions parser/v2/elementparser.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var elementOpenTagParser = parse.Func(func(pi *parse.Input) (e elementOpenTag, o
return
}

// if any attr is not on the same line as elm name then we will indent them
// If any attribute is not on the same line as the elemenet name, indent them.
if pi.Position().Line != l {
e.IndentAttrs = true
}
Expand Down Expand Up @@ -342,7 +342,7 @@ func (elementOpenCloseParser) Parse(pi *parse.Input) (r Element, ok bool, err er
if r.Children, ok, err = newTemplateNodeParser[any](nil, "").Parse(pi); err != nil || !ok {
return
}
// if all the children are not on the same line indent them
// If the children are not all on the same line, indent them
if l != pi.Position().Line {
r.IndentChildren = true
}
Expand Down Expand Up @@ -393,7 +393,7 @@ var selfClosingElement = parse.Func(func(pi *parse.Input) (e Element, ok bool, e
return
}

// if any attr is not on the same line as elm name then we will indent them
// If any attribute is not on the same line as the element name, indent them.
if pi.Position().Line != l {
e.IndentAttrs = true
}
Expand Down
3 changes: 1 addition & 2 deletions parser/v2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -451,8 +451,7 @@ func writeNodes(w io.Writer, indent int, nodes []Node, block bool) error {
// Terminating and leading whitespace is stripped.
_, isWhitespace := nodes[i].(Whitespace)

// allow a single space between StringExpressions
// prevents <div>{firstName} {lastName}</div> from becoming <div>{firstName}{lastName}</div>
// Allow a single space between StringExpressions to prevent <div>{firstName} {lastName}</div> from becoming <div>{firstName}{lastName}</div>.
if isWhitespace && !block && previousIs[StringExpression](nodes, i) && futureHasAnythingOtherThan[Whitespace](nodes, i) {
w.Write([]byte(" "))

Check failure on line 456 in parser/v2/types.go

View workflow job for this annotation

GitHub Actions / lint

Error return value of `w.Write` is not checked (errcheck)
continue
Expand Down
4 changes: 2 additions & 2 deletions parser/v2/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ templ table(accountNumber string, registration string) {
`,
},
{
name: "conditional expressions result in all atters indented",
name: "conditional expressions result in all attrs indented",
input: ` // first line removed to make indentation clear
package test
Expand All @@ -385,7 +385,7 @@ templ conditionalAttributes(addClass bool) {
`,
},
{
name: "conditional expressions result in all atters indented, 2",
name: "conditional expressions result in all attrs indented, 2",
input: ` // first line removed to make indentation clear
package test
Expand Down

0 comments on commit 4deabea

Please sign in to comment.