XRss is a simple RSS reader web app built to showcase xtemplate, a new web development tool based on Go's html/template and Caddy server.
The entire site UI for XRss comes from a single HTML template file. This index.html includes everything from SQL queries and route definitions and handlers to htmx state transition attributes and tailwindcss classes, and developing it requires zero build steps (amortized).
Check out the source which manages to be at once banal and gnarly: https://github.com/infogulch/xrss/blob/master/templates/inde...
xtemplate preloads the whole template structure into memory and builds the router at startup, so responses to matching requests are rendered after a single lookup. Combined with direct queries to sqlite makes for a very snappy experience typically responding in less than 5ms. (Fingers crossed.)
There are various places where XRss could be improved (PRs welcome!), but it already delivers on its purpose of demonstrating the plausibility of xtemplate. See the xtemplate readme for an overview of what you can do with it. I think of it as 'PHP but the syntax looks like Go templates'.
https://github.com/infogulch/caddy-xtemplate
Let me know what you think! Does remaking PHP from scratch out of Go templates make me a lunatic? (yes) Is it a good idea anyway? (yes) What kind of web application do you think would be a good fit for a platform like this?
I found htmx recently and it's exciting to me because its potential to vastly simplify website development experience without compromising on user experience. One design principle that htmx is based on, Locality of Behavior, is particularly eye-opening. ( https://htmx.org/essays/locality-of-behaviour/ ) Yet despite htmx simplifying the frontend, actually writing the matching backend is still messy because existing tools funnel developers to separate concerns rather than co-locate behaviors.
xtemplate was written out of spite from being forced to jump between half a dozen files just to add simple backend functionality: define a new route, code up yet another repository, fight the ORM's stupid query generator, create a new handler, manually wire it up to a template, blah blah blah. Screw it, what if you just put everything in the damn html? I happen to be familiar with Go's template modules, and it turns out they are naturally suited to htmx apps because of their flexibility and the ease of defining and reusing inline template fragments.
So I ran with it and tried it with a todomvc-style app in the now archived `go-htmx` repo. Eventually I stumbled on Caddy's template module, and realizing that I could skip all the web server-related feature development by integrating with Caddy I rebased onto it to get a head start. The next thing it needed was a consuming project, small enough it could be completed in a reasonable time, but not so small that it's not useful. So XRss was born.