Open josharian opened 2 years ago
This obviously can't be solved in the general case. (The if statement could call a Go function, so solving this is equivalent to solving the halting problem.) But some common cases could be special-cased to handle most scenarios.
While not exactly the same. This seems like a similar scenario that can be handled correctly every time because the same tag is used in both the if and the else block:
{{ define "test" }}
{{ if .Active }}
<li class="active">
{{ else }}
<li class="inactive">
{{ end }}
</li>
{{ end }}
[error] test.html: Error: An error occured during printing. Found invalid node root.
We have code structurally similar to this (only more complex, with different tags):
This yields:
This is similar to https://github.com/NiklasPor/prettier-plugin-go-template/issues/59, but it causes an error instead of duplication.