Adrian Hesketh, the creator of Templ, and Joe Davidson, a maintainer on the project, discuss Templ, an HTML templating language for Go. They explore the challenges of using the html/template package in Go and highlight the benefits of using Templ. They also touch on topics such as server-side rendering, the functionality and design of Templ, managing open source projects, and expanding the community. Additionally, they have a fun discussion about wearing socks with sandals and the debate over athleisure fashion.
Templ is a new HTML templating library for Go that aims to provide an improved experience compared to the built-in HTML/template package, offering features like auto completion, type safety, and better error handling.
Templ differentiates itself with features like auto completion for template code and seamless integration with Go code, providing excellent performance and prioritizing security with Google Safe HTML integration.
Server-side rendering is still widely used in web applications, particularly for government agencies, to ensure accessibility, user-friendly experiences, and improved page load speeds.
Deep dives
Building a Better HTML Templating Library
Temple is a new HTML templating library for Go that aims to provide an improved experience compared to the built-in HTML/template package. The motivation behind building Temple came from the frustration with the limitations and lack of features in the existing templating options available for Go. The goal of Temple is to make templating in Go more ergonomic and familiar, similar to languages like JSX or Razor views. The library offers features like auto completion, type safety, and better error handling to enhance the development experience. Temple also supports component-based design, allowing developers to reuse and share functionality across different projects.
The Features and Design Philosophy of Temple
Temple differentiates itself with features like auto completion for template code, making it easier to avoid errors and typos. It provides a seamless integration with Go code, allowing developers to write Go code directly inside the template without any restrictions. Temple generates pure Go code from the templates, which provides excellent performance. The library also prioritizes security, thanks to its integration with the Google Safe HTML project, ensuring that user-generated content is properly escaped to prevent code injection. The design philosophy of Temple centers around simplicity, familiarity, and extensibility, enabling developers to build web applications with Go in a concise and efficient manner.
The Vision and Adoption of Temple
Temple aims to be a viable alternative to popular front-end frameworks like React. It is suitable for a wide range of web applications, from internal admin systems to complex production workloads. The library is designed to be sustainable and actively maintained and welcomes contributions from the community. The project prioritizes clear and comprehensive documentation, making it easier for developers to start using Temple and understand its features. Overall, Temple brings a modern, developer-friendly approach to HTML templating in Go, offering a powerful and flexible solution for building web applications.
Server-side rendering for accessibility and simplicity
Server-side rendering is still widely used, particularly in government agencies, to ensure accessibility and user-friendly experiences in web applications. By rendering on the server, screen readers can effectively interpret the content and avoid accessibility issues like screen flashing. Server-side rendering also simplifies the learning curve for new developers, as it is often easier to understand and work with compared to complex JavaScript frameworks. Additionally, server-side rendering can improve page load speeds, making it a viable option for modern web development.
The appeal of server-side rendering for documentation and microfrontends
Server-side rendering has distinct advantages for specific use cases, such as documentation websites and microfrontends. In documentation websites, server-side rendering ensures good SEO performance and provides a natural search experience. Microfrontends can benefit from server-side rendering, allowing for easy scaling and independent development of different sections owned by separate teams. HTMLX, a modern web development approach, further enhances server-side rendering capabilities with features like dynamic element replacement and low latency server communication. Server-side rendering with HTMLX simplifies web app development while maintaining excellent performance and scalability.
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!