Templ

I enjoy writing code in Go, but an easy critique of it is templating doesn’t feel good. I’ve only just heard of Templ and it looks fabulous. You make .templ files which contain what look like JSX functions. They take typed params and have an implied return of the HTML they contain

templ headerTemplate(name string) {
  <header id="site-header">
    <h1>{ name }</h1>
  </header>
}Code language: Go (go)

These .templ files compile into Go code then you use them there. It looks so smoothly ergonomic, especially how other code/logic is incorporated (just… start a line with code, not an angle bracket). It’s one of those bits of tech that make me want to find an excuse to use it.

Need front-end development training?

Leave a Reply

Your email address will not be published. Required fields are marked *

Did you know?

Frontend Masters Donates to open source projects. $363,806 contributed to date.