Adrian Hesketh, creator of Templ, and Joe Davidson, maintainer on the project, join hosts Kris Brandow and Jon Calhoun to discuss Go templating. They talk about the motivation behind creating Templ, the benefits of server-side rendering, using Temple to call Go functions in templates, and fashion trends in the tech industry.
Templ is a Go templating library designed to simplify HTML templating and improve the developer experience.
Templ leverages the Go Language Server Protocol (LSP) to provide powerful features such as auto-completion and error checking within the editor.
Templ aims to simplify the process of building web apps by providing a familiar Go-like syntax and supporting interoperability with other front-end tools.
Deep dives
Overview of Temple
Temple is a templating library designed for Go that aims to simplify HTML templating and improve the developer experience. It was created due to frustrations with the built-in Go template engine, which lacked features such as auto-completion and had some design limitations. Temple provides a more Go-like syntax for templates, allowing developers to write templates as functions in Go code. It also supports component-based design, making it easier to reuse and share functionality across projects. The goal of Temple is to offer a valid and viable alternative to popular front-end frameworks like React, while still leveraging the power and simplicity of Go.
The Process of Building Temple
The development of Temple involved building a new parser for HTML templates and integrating with the Go Language Server Protocol (LSP). The LSP integration allows for powerful features such as auto-completion, go-to-definition, and error checking within the editor. By generating Go code from the template, Temple leverages the existing Go tooling and ecosystem. The project started as a proof-of-concept to add LSP features to the existing quick template library, but evolved into a separate project with its own syntax and design. The development process focused on usability, extensibility, and performance, with optimizations made to ensure fast rendering and responsiveness.
Use Cases and Future Vision
Temple is suitable for a variety of web applications, from internal admin systems to full-fledged web apps. It aims to simplify the process of building web apps by providing a familiar Go-like syntax and leveraging existing Go code. Temple is designed to be flexible and interoperable, allowing developers to use HTMLX, CSS libraries, and other front-end tools alongside it. The project is open-source and actively maintained, with a growing community and contributions from users. The future roadmap includes improvements in editor support, such as GoLand integration, and potentially generating documentation with Temple itself.
Server-side rendering and accessibility in government services
The podcast episode discusses how government agencies, such as GDS in the UK, prioritize accessibility in their services, leading to the use of server-side rendering for improved usability. By using server-side rendering, websites and apps can be designed to be more straightforward and accessible to a wide range of users, including those with temporary vision or technology adaptation challenges.
Challenges of adopting new technologies and the power of HTMLX
The podcast episode explores the difficulty of adopting new technologies and the syntax overload that developers often face, particularly with languages like TypeScript. The discussion emphasizes the need for simplified and approachable tools in web development. The HTMLX library is highlighted as an example of a powerful yet easy-to-use tool that simplifies rendering speed on the server-side and enables dynamic content replacements. HTMLX is praised for its potential to provide a more streamlined and ergonomic development experience, particularly for applications that do not require complex front-end solutions.
Go’s known for it’s fantastic standard library, but there are some places where the libraries can be challenging to use. The html/template package is one of those places. So what alternatives do we have? On today’s episode we’re talking about Templ, an HTML templating language for Go that has great developer tooling. Co-hosts Kris Brandow and Jon Calhoun are joined by Adrian Hesketh, the creator of Templ, and Joe Davidson, one of the maintainers on the project.
Changelog++ members save 2 minutes on this episode because they made the ads disappear. Join today!
Sponsors:
Fastly – Our bandwidth partner. Fastly powers fast, secure, and scalable digital experiences. Move beyond your content delivery network to their powerful edge cloud platform. Learn more at fastly.com
Fly.io – The home of Changelog.com — Deploy your apps and databases close to your users. In minutes you can run your Ruby, Go, Node, Deno, Python, or Elixir app (and databases!) all over the world. No ops required. Learn more at fly.io/changelog and check out the speedrun in their docs.
Typesense – Lightning fast, globally distributed Search-as-a-Service that runs in memory. You literally can’t get any faster!