More Premium Hugo Themes Premium Html Themes

Xtemplate

A html/template-based hypertext preprocessor and rapid application development web server written in Go.

Xtemplate

A html/template-based hypertext preprocessor and rapid application development web server written in Go.

Author Avatar Theme by infogulch
Github Stars Github Stars: 88
Last Commit Last Commit: Sep 3, 2025 -
First Commit Created: Oct 26, 2023 -
Xtemplate screenshot

Overview

XTemplatextemplate is a hypertext preprocessor that extends Go’s html/template library to be capable enough to host an entire server-side web application using just template definitions. It is designed with the htmx.org JS library in mind, which makes server-side rendered sites feel as interactive as Single Page Apps. However, it is important to note that this project is still in development.

Features

  • Query the database directly within template definitions, with automatic input sanitization to prevent basic XSS attacks.
  • Define templates and import content from other files.
  • File-based routing, where GET requests for a path with a matching template file will invoke the template file at that path, excluding files starting with “_”.
  • Create custom routes with parametrized paths using the <method> <path> pattern, with path parameters and wildcards available as values in the template.
  • Automatic reload of templates, with validation, as soon as they are modified, eliminating the need to restart the server.

Installation

To use XTemplatextemplate, you will need to include the following packages in your Go application:

  • github.com/infogulch/xtemplate: a library that loads template files and implements http.Handler. Use it by depending on it as a library and utilizing the XTemplate struct.
  • github.com/infogulch/xtemplate/bin: a simple binary that configures XTemplate with CLI args and serves HTTP requests. Build it yourself or download the binary from GitHub releases.
  • github.com/infogulch/xtemplate/caddy: a Caddy module that integrates XTemplate into the Caddy web server.

Summary

XTemplatextemplate is a tool that extends Go’s html/template library to enable the creation of server-side web applications using only template definitions. It offers features such as querying the database within templates, importing content from other files, file-based routing, custom routes, and automatic template reloading. Although this project is still in development, it shows promise in simplifying web application development and making server-side rendered sites more interactive.