Some apps need to allow users to customise the appearance of sections of the site.
With Go stdlib templates, it's possible to dynamically load templates, but templ components are compiled into Go code. Compiling to Go gives performance benefits, as well as compile time checking, but it makes it difficult to allow customisation of the site, because Go can't easily load and execute compiled code (e.g. dynamic loading of a DLL in C#).
However, we can use remote components.
In this design, a user writes a web server that implements the custom templates, and the application loads them dynamically, replacing the HTML content.
When the custom template server is running, you can access them via curl, e.g. curl -X POST --data '{"User":{"Name": "Adrian"}}' localhost:8090/header to render the header.
Running this will start the app without any custom templates. You will see "standard header" etc.
go run ./app/ serve
If you run the custom template server, then run run-app-with-custom, you will see "Custom header" etc.
go run ./custom/
go run ./app/ serve --remote-templates-base-url="http://localhost:8090"