Ludic: New framework for Python with seamless Htmx support

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

Our great sponsors
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • WorkOS - The modern identity platform for B2B SaaS
  • SaaSHub - Software Alternatives and Reviews
  • ludic

    🌳 Lightweight framework for building dynamic HTML pages in pure Python.

  • In general, this usually results in front-end logic being very tightly coupled with back-end logic. In some of the examples given, you even have database access in the same line that is generating the HTML document.

    https://github.com/paveldedik/ludic/blob/main/examples/click...

    It's the kind of thing that looks very cool and concise in small examples, but tends to become a nightmare when you are working on larger projects.

  • hotmetal

    A tiny HTML generator

  • I wrote a library a little while ago which is intended to be the simplest possible expression of this idea:

    https://github.com/j4mie/hotmetal/

    The core implementation is only 85 lines of Python, and has no imports at all, so works nicely on minimal implementatons like Micropython.

    I'm using it on a medium-sized side project and it's shockingly productive compared to string templates. I don't think anyone is using it except me, though.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • kotlin-htmx

    https://corlaez.com/assets/htmx/index.html

  • I encourage anyone looking to do htmx to consider Kotlin and it's excelent kotlinx-html DSL. Lets you do stuff like this: https://github.com/corlaez/kotlin-htmx/blob/master/src/main/...

    Disclaimer: Not my code, just an example I found.

  • compone

    Component framework for Python

  • I also started working on a Python Component library, but it's fully independent of any web framework, and you can generate XML/RSS with it too. I'm using it for months now, I will release the first version soon: https://github.com/kissgyorgy/compone

  • reagent

    A minimalistic ClojureScript interface to React.js

  • Generating `HTML` from lisps has poisoned any other approach for me, see for example https://www.neilvandyke.org/racket/html-writing/, https://reagent-project.github.io/, and https://edicl.github.io/cl-who/

  • Mithril.js

    A JavaScript Framework for Building Brilliant Applications

  • The idea of nested function calls to build HTML is not new. Back in the hey-day of JS frameworks, this was a common vdom pattern. I kinda miss [MithrilJS](https://mithril.js.org/#dom-elements)

  • webbits

  • I have been working on a (currently half-baked) similar project:

    - <https://github.com/abilian/webbits>

    Inspirations for the idea of generating HTML code from Python:

    - <https://www.yattag.org/>

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • packed

    Discontinued JSX-style syntax preprocessor for Python

  • - <https://github.com/michaeljones/packed>

  • mixt

    Write html components directly in python and you have a beautiful but controversial MIXTure

  • domonic

    Create HTML with python 3 using a standard DOM API. Includes a python port of JavaScript for interoperability and tons of other cool features. A fast prototyping library.

  • htm.py

    Discontinued JSX-like syntax in plain Python

  • fast_html

    Generate HTML conveniently and efficiently in Python

  • html5tagger

    Create HTML documents from Python

  • htmxido

    HTMX generation in Python 3 using DSL

  • On similar lines, I've put together a library for myself that is framework agnostic:

    https://github.com/maxpert/htmxido

    Hopefully will be useful for people as well

  • neat-html

    A python library for writing and composing HTML.

  • I've also been working on a library with a similar idea:

    https://github.com/SamDudley/neat-html

    It's still a work in progress so an example might be better to look at:

    https://github.com/SamDudley/neat-html/blob/main/examples/fo...

    I was inspired by some JavaScript libraries that I've used in the past:

    * https://github.com/jorgebucaran/hyperapp

  • hyperscript

    Create HyperText with JavaScript.

  • * https://github.com/hyperhype/hyperscript

    There is also a working integration with Django that enables the use of neat-html as a template backend, however it isn't up on GitHub yet.

    I find the space of HTML generation libraries which can leverage the power of Python, really interesting.

  • mountaineer

    Mountaineer is a batteries-included web framework for Python.

  • I imagine a lot of this comes down to personal preference. In the early days of Mountaineer (gee, almost two months ago at this point), I played around with the idea of embedding html into python instead of needing a JS layer. Eventually my consensus was:

    - The most extensive typehinted approaches typically end up wrapping JS/React components anyway (like Reflex/Pinecone)

    - We really need better IDE support for html strings that are within python strings. The editing problem is a big setback.

    The ergonomics of Python + JS in separate code files won out and the user experience has been better than forcing them both into a common language would be.

    This has the benefit of leveraging whatever the two languages are best at, in native code, so you have access to all the native APIs without having to learn a shim on top of it. Way more longevity to that approach too. Context switching between two languages isn't that bad if you minimize the glue layer that you have to write between them.

    [^1]: https://github.com/piercefreeman/mountaineer

  • nevow

    Web Application Construction Kit

  • see also: twisted nevow + stan, which I believe predate the term 'AJAX'.

    https://github.com/twisted/nevow/blob/master/examples/simple...

  • zakuchess

    A free and open-source "daily chess challenge" game, where you play against a computer opponent with pixel art graphics from The Battle for Wesnoth

  • It feels weird at the beginning, but after a bit of practice I found it pretty nice to write HTML in Python.

    Here is an example of a HTML page layout written with the DOMinate [1] library for example, in a "JSX-like" way:

    https://github.com/olivierphi/zakuchess/blob/main/src/apps/w...

    It may hurt your eyes at first sight, for sure... But similarly to technologies like Tailwind CSS, it's mostly a matter of getting used to it - and after a while it end ups feeling very natural to use :-)

    1: https://github.com/Knio/dominate#readme

  • 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.

  • It feels weird at the beginning, but after a bit of practice I found it pretty nice to write HTML in Python.

    Here is an example of a HTML page layout written with the DOMinate [1] library for example, in a "JSX-like" way:

    https://github.com/olivierphi/zakuchess/blob/main/src/apps/w...

    It may hurt your eyes at first sight, for sure... But similarly to technologies like Tailwind CSS, it's mostly a matter of getting used to it - and after a while it end ups feeling very natural to use :-)

    1: https://github.com/Knio/dominate#readme

  • sneeze

    Render Elixir data-structures to HTML, inspired by Hiccup.

  • Elm

    Compiler for Elm, a functional language for reliable webapps.

  • Elm [1] is based on a similar idea. Build your app from pure functions that return HTML tags.

    [1] https://elm-lang.org/

  • hyperdiv

    Build reactive web UIs in Python

  • Nice! A bit verbose for my taste but writing for the web in python is a space where all innovation is welcome.

    I personally like hyperdiv [1] approach (even if no use of Htmx) which is very intuitive for python code.

    [1]: https://github.com/hyperdiv/hyperdiv

  • PHPTAL

    PHP Template Attribute Language — template engine for XSS-proof well-formed XHTML and HTML5 pages

  • I agree and I don't fully understand the why of it.

    I remember coding PL/SQL to emmit HTML in Oracle around 1999 or 2000 and using functions to code the various elements.

    Thay got old and repetitive very quickly - for instqance, everytime I had to correct a spelling error, I had to recompile the code.

    To get around it I used one or two tables to hold html snippets to decouple the business/backend logic from the frontend, and stopped using the PL/SQL functios completely.

    My speed of developmet skyrocketed, and separating and abstracting the frontend from the backend made so much sense.

    A few years later, I was doing web developemt with Python using the Zope framework (not many people know about it tiday, I think).

    It uses a specialised serverside templating language called TAL (Template Attribute Language)[1] that basically builds the front end dynamically, and then you feed it data from the backend.

    Very neat and allowed me to build reusable compoments as well as collections of a schema definition (basically a dict), html template(s) and the code to validate that the inpuy matched the schema and could be rendered.

    Or something like that its been 2 employers and almost 20 years since i worked with tha :)

    I did build a small php extension for Wordpress using a PHP implementation[2] of TAL a few years ago, and TAL still works like a charm :)

    My point is that I still believe there is value in keeping python out of the HTMl-templating, and in keeping the front end logic apart from the backend logic.

    There is something I am not understanding about the renewal of mixing HTML/GUI template with code, buy I haven't fully found it yet.

    [1] https://en.m.wikipedia.org/wiki/Template_Attribute_Language

    [2] I believe it was this one https://phptal.org/

  • SaaSHub

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

    SaaSHub logo
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