Xtemplate

screenshot of Xtemplate
html

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

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.

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.

html
HTML

HTML templates are pre-designed and pre-built web pages that can be customized and used as a basis for building websites. They often include common elements such as headers, footers, menus, and content sections, and can be easily edited using HTML and CSS to fit specific branding and content needs.