talira

An HTML templating language for Go that has great developer tooling

open sourceMITself-hostablefree

templ is a language for writing HTML user interfaces in Go. You write components in .templ files that mix HTML with Go expressions and ordinary if, switch and for statements, and the templ CLI compiles them into type-checked Go code that renders HTML fragments, pages or whole apps. Components compose, call any Go code and need no JavaScript on the client or server. It renders on the server (as a standard Go program, a container or a serverless function) or generates static HTML files, and its language server gives editors autocompletion, formatting and error checking. It is often paired with htmx.

Problems it solves

  • write HTML templates in Go with type checking and editor autocompletion
  • build server-rendered Go web pages from reusable components
  • generate a static site from Go code
  • replace html/template because typos only show up at runtime

Features

  • HTML components compiled to Go code
  • type-checked templates
  • use Go if, switch and for statements
  • server-side rendering
  • static HTML generation
  • language server with IDE autocompletion
  • code formatter
  • no JavaScript required