Skip to content

[BUG] [Linter] H025 false positive: multiline Go template expression with quotes in HTML attribute #1678

@silverwind

Description

@silverwind

Filed by Claude on behalf of @silverwind

Description

H025 produces a false positive when an HTML attribute contains a Go template expression ({{...}}) that spans multiple lines and includes quoted strings. The inner " characters are misinterpreted as closing the HTML attribute value, causing the opening tag to not be recognized by the H025 tag scanner.

Minimal reproduction

Fails (multiline template expression with inner quotes):

<div>
	<div data-x="{{Func
		"a"}}"></div>
</div>
H025 4:0 Tag seems to be an orphan. </div>

Works (same template expression on a single line):

<div>
	<div data-x="{{Func "a"}}"></div>
</div>

Root cause

The attribute pattern regex uses {{.*?}} to match template expressions inside attribute values. On a single line this works because .*? matches everything between {{ and }}. But when the expression spans multiple lines and contains " characters, the regex engine appears to interpret the inner " as closing the HTML attribute's double-quote delimiter before the {{.*?}} pattern can consume the full expression.

Environment

  • djlint 1.36.4
  • Profile: golang

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions