diff --git a/parser/v2/elementparser.go b/parser/v2/elementparser.go index e75e17701..cf83b4ef2 100644 --- a/parser/v2/elementparser.go +++ b/parser/v2/elementparser.go @@ -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 } @@ -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 } @@ -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 } diff --git a/parser/v2/types.go b/parser/v2/types.go index e97afcdc6..545878ffa 100644 --- a/parser/v2/types.go +++ b/parser/v2/types.go @@ -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
{firstName} {lastName}
from becoming
{firstName}{lastName}
+ // Allow a single space between StringExpressions to prevent
{firstName} {lastName}
from becoming
{firstName}{lastName}
. if isWhitespace && !block && previousIs[StringExpression](nodes, i) && futureHasAnythingOtherThan[Whitespace](nodes, i) { w.Write([]byte(" ")) continue diff --git a/parser/v2/types_test.go b/parser/v2/types_test.go index 72abbee7c..5986d28d8 100644 --- a/parser/v2/types_test.go +++ b/parser/v2/types_test.go @@ -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 @@ -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