a-h / templ

A language for writing HTML user interfaces in Go.
https://templ.guide/
MIT License
7.14k stars 236 forks source link

Fix for Issue #775: Prevent Duplicate Import Statements in Generated Templates #776

Closed akdotio closed 1 week ago

akdotio commented 1 month ago

This PR addresses issue #775, where duplicate import statements in generated templates caused go build to fail.

Changes Made:

With these changes, the generator will no longer produce duplicate import statements, ensuring successful builds.

a-h commented 1 week ago

Thanks a lot for for putting this together, but we realised that we needed to sort out the organisation of imports too, so we've implemented a fix for the imports more generally at https://github.com/a-h/templ/pull/793

It makes it so that there's only two imports - templ, and templruntime, so the generated code won't have magic imports that you can't see like io etc. Additionally, any missing imports will be added automatically.