That people produce HTML with string templates is telling us something

This page summarizes the projects mentioned and recommended in the original post on news.ycombinator.com

SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  1. htmlgo

    A library for writing type-safe HTML in Golang

    I just switched my project from open-coded SQL to goqu; inspired by this article, I searched for "golang html builder" and got this project:

    https://github.com/julvo/htmlgo

    Which definitely looks interesting.

  2. SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
  3. hiccup

    Fast library for rendering HTML in Clojure

    That is why I like Hiccup/ Clojure so much: https://github.com/weavejester/hiccup It is very natural to produce something resembling a document in pure Clojure data structures and then just convert it to valid HTML. I think, Reagent has some hiccup extensions that are nice like writing the class or id with a . or # notation right in the keyword describing the tag. So there probably still is some space to improve the ergonomics and probably performance. Concatenating strings still wins performance wise by a lot.

  4. sqlc

    Generate type-safe code from SQL

    In a similar-but-also-totally-opposite vein to goqu is sqlc [1], where you write the SQL and the Go bindings get generated.

    [1] https://sqlc.dev/

  5. dom

    DOM Standard

    JSX chose to align names to the DOM spec [0]. Same for htmlFor and friends.

    [0] https://dom.spec.whatwg.org/#ref-for-dom-element-classname%E...

  6. vtpl

    Vtpl is a php template engine that ensures proper separations of concerns, the frontend logic is separated from presentation. The goal is to keep the html unchanged for better maintainability for both backend and frontend developers

  7. flog

    Pre-Markdown static site generator based on UNIX tools and XSL (by jaredkrinke)

    XSLT has a steep learning curve and it’s extremely verbose. But my main problem with it is that (as far as I know) XHTML isn’t being updated alongside the current HTML spec (with semantic elements).

    Related: I’ll admit that I used to use XSLT for my static site generators [1] and now I’ve switched to string interpolation (with conservative escaping as the default) [2].

    [1] https://github.com/jaredkrinke/flog/blob/main/post.xsl

    [2] https://github.com/jaredkrinke/literal-html

  8. literal-html

    Simple and unsafe HTML/XML templates for TypeScript, using tagged template literals

    XSLT has a steep learning curve and it’s extremely verbose. But my main problem with it is that (as far as I know) XHTML isn’t being updated alongside the current HTML spec (with semantic elements).

    Related: I’ll admit that I used to use XSLT for my static site generators [1] and now I’ve switched to string interpolation (with conservative escaping as the default) [2].

    [1] https://github.com/jaredkrinke/flog/blob/main/post.xsl

    [2] https://github.com/jaredkrinke/literal-html

  9. template

    A simple framework for webapps (by retrohacker)

    I’ve been using to avoid the whole “create DOM elements in JS” thing, and it’s been working well so far:

    https://github.com/retrohacker/template

  10. dominate

    Dominate is a Python library for creating and manipulating HTML documents using an elegant DOM API. It allows you to write HTML pages in pure Python very concisely, which eliminate the need to learn another template language, and to take advantage of the more powerful features of Python.

    You're conflating two things, dynamically creating HTML is great and lets you avoid JS in a lot of cases. It's whether you should treat your HTML document as the tree of nodes that it is in your programming language or treat it like a string.

    https://github.com/Knio/dominate is a Python lib that implements this principal.

  11. gron

    Make JSON greppable!

    A useful tool for transforming JSON to and from a format that is more amenable to simple text tooling is gron: https://github.com/tomnomnom/gron

    Takes all the tree and hierarchy management away, makes it so ordering doesn’t matter.

    If I’m generating JSON from batch scripts it’s my preferred tool (easier than fighting jq for many tasks)

  12. rum

    Simple, decomplected, isomorphic HTML UI library for Clojure and ClojureScript

    (Note that Rum is also a React wrapper, but you don't have to use that part of it; you can simply use it for static rendering of HTML.)

    https://github.com/tonsky/rum

  13. phpStageManager

    Discontinued Web-based theatre management utility

    "Nobody ever generates JSON using string interpolation." Oh boy, you just took me back to my first ever PHP project. Feast your eyes: https://github.com/oxguy3/phpStageManager/blob/master/events...

    This file generates a feed of events (rehearsals for my high school play) to be rendered by the FullCalendar JS plugin. FullCalendar required a particular data schema that didn't match the format of my MySQL table, which meant I couldn't just json_encode() the MySQL results. I guess I just didn't conceptualize that I could create a new object that matched the FullCalendar format, and then call json_encode(). So, I generated JSON with strings.

    Honestly it's a toss-up whether the JSON generation is the worst thing about this file. It looks like I also made a separate database query for every single row to get the username, because I apparently didn't know how to do joins. Could probably spend an hour listing some of the other little nuggets of awful in there. But hey, it got the job done! :)

  14. dream-html

    Type-safe markup rendering, form validation, and routing for OCaml Dream web framework

    I found your article very informative and it matches up quite a bit with my own thinking about HTML generation. In fact it looks like we independently arrived at pretty much the same conclusions. A lot of the issues you raise are the impetus behind the way I designed my HTML-generation DSL: https://github.com/yawaramin/dream-html

  15. nano

    🎯 SSR first, lightweight 1kB JSX library. (by nanojsx)

    for sure not suggesting using E4X as it is, JSX has evolved a lot from E4X. For example, as small implementation such as https://nanojsx.io would be a good start.

  16. jsonnet

    Jsonnet - The data templating language

    Apologies for the lack of context, and for missing this comment until today.

    Both are tools for defining kubernetes manifests (which are YAML) in a reusable manner.

    Jsonnet is a formally specified extension of JSON. It’s essentially a functional programming language (w/some object oriented features) that generates config files in JSON/YAML/etc, so it’s straightforward to determine whether an input file is valid, and to throw an error that points to an exact line if it’s not. It has a high learning curve, especially for people whose only experience is with imperative languages.

    https://jsonnet.org/

    Helm charts also generate YAML/JSON config files, but they use Go templating. This is easier and faster to understand, since it’s mostly string substitution and not much logic (there’s conditionals, iterators, and very basic helper functions). Unfortunately a simple typo or mistake can cause errors that are difficult to diagnose (the message may indicate a problem far away in code from the actual mistake). It can also generate output that’s valid according to the string templating rules, but not what was intended, which can be very confusing to debug.

    Despite these shortcomings, the vast majority of kubernetes applications are distributed as helm charts. I understand why things ended up this way, but I still wish it were more common for people to invest the upfront effort to learn the superior tool, so it could be more widespread.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Server Sent Events 101

    1 project | dev.to | 11 Jan 2025
  • Converting Plotly charts into images in parallel

    2 projects | dev.to | 2 Jan 2025
  • Bringing Feedback Loops to API Development

    3 projects | dev.to | 19 Dec 2024
  • Dominate: A Python/JavaScript lib for generating HTML documents

    2 projects | news.ycombinator.com | 13 Dec 2024
  • Semaphore UI: Modern UI/API for Ansible, Terraform, OpenTofu, PowerShell

    1 project | news.ycombinator.com | 11 Dec 2024

Did you know that Go is
the 4th most popular programming language
based on number of references?