Nice release! This looks good, docs look really nice too. I'd use HTMX anywhere I can to improve a basic HTML site. One word of warning for people considering HTMX though – it's not a framework, it's an appliance. In my experience with it, I ran into problems integrating with HTMX very quickly. Drop it into your project, use the HTML attributes, and it'll be great. However if you need custom Javascript, HTMX provides…
True, I can recommend hotwire turbo as an alternate similar to htmx, it has a js framework called Stimulus that integrates nicely for those instances where you need some custom interactivity.
Ludic: New framework for Python with seamless Htmx support
91–100 of 107 posts
Re: Ludic: New framework for Python with seamless Htmx support
#92Earlier quoted context omitted.
React can be added by rendering into a dom node that's not necessarily the root of your app. Yes, it can be used to render the entire UI app with rich state management across all pages, routing, etc. However it can just as simply be used to render 1 complex part of an app that has an isolated but possibly complex state. In this scenario I think sprinkling react is reasonable.
I'm admittedly out of touch with current React best practices, but "sprinkling react" isn't a phrase I'd have expected to hear based on my last contact with it. Sprinkling JavaScript or Alpine.js or HTMX, yes. But React seems to come with baggage, no?
At that point, you can just write your own Javascript functions / classes for rendering, and handle your own state management
HTMX lends itself more to "sprinkling". Its basically just a very compact version of fetch(), combined with trigger logic (e.g. setTimeout(), onclick, etc.
Re: Ludic: New framework for Python with seamless Htmx support
#93I wish someone would sponsor development of HTMX support via NginX or Apache2 modules. That way you don't have to go to python, php, java, etc... to get HTMX support. You would just enable the module, configure a few things and let it rip. Kinda like server side includes in Apache2.
Can you explain what you mean? htmx is client-side, so you don't need server-side includes. Just host HTML snippets on your web server and let htmx stitch them together in the browser. I'm not sure where you want the web server to play a role?
Re: Ludic: New framework for Python with seamless Htmx support
#94I 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/ > - https://tylerbakke.github.io/MarkupPy/ > - https://github.com/michaeljones/packed > - https://github.com/twidi/mixt/ > - https://github.com/byteface/domonic > - https://pypi.org/project/hyperpython/ > - https://pypi.org/pro…
Most of the frameworks here are calling side effects upon shared objects in the guise of `with` statements. Not to mention the extreme verbosity.
>
>
>
>
>
> [longcode1() if cond else longcode2()]
>
>
>
>
>[longcode() for i in ls]
Re: Ludic: New framework for Python with seamless Htmx support
#95Earlier quoted context omitted.
Can you explain what you mean? htmx is client-side, so you don't need server-side includes. Just host HTML snippets on your web server and let htmx stitch them together in the browser. I'm not sure where you want the web server to play a role?
HTMX is a client side JS file which parses the dom and then interprets it in a certain way and then provides some functionality. However the choice whether someone creates the initial html in a SPA context or a full page refresh is up to the developer. Maybe I want to generate the HTML snippets HTMX processes from the server side in PHP/Python and then have HTMX run it's magic on page load.
Complicating them with hooks for a bunch of random APIs is asking for trouble. Let the application servers sit behind them so they don't have to worry about those issues, and nginx/apache don't have to worry about application server issues
Re: Ludic: New framework for Python with seamless Htmx support
#96Earlier quoted context omitted.
Interestingly, the second example on the official Ruby "About" page is almost exactly that: it defines .plus to be an alias of .+, and demonstrates how it might be used. https://www.ruby-lang.org/en/about/ As a web developer (and therefore, I imagine, part of the target demographic for this sort of tool), I personally find this component example very useful. Components are very powerful, but most existing Python temp…
That's a totally different presentation though. The ludic home page never mentions that there is an existing function/data type! It just goes straight into the definition of Link without giving any context to someone who doesn't know what htmx is. There is nothing to tell a naive reader that this isn't how you'd do this in a production app.
Re: Ludic: New framework for Python with seamless Htmx support
#97This looks great! Building HTML on the server with static types and htmx is a very productive combination! At work, we have been exploring alternatives to templates in our Django project and just released it as a lib to help with this: https://htpy.dev/
Have you tried to "bring up front" if and for? For example
> if_(cond, tag1(), tag2()) # without eagerly execute both branches
Instead of
> tag1() if cond else tag2()
And
for_(cars, lambda car: car_details(car)) # while still being type checked
Instead of
> [car_details(car) for car in cars]
Re: Ludic: New framework for Python with seamless Htmx support
#98Call me traumatized by the Web framework wars, but this seems like the path back to some of the issues that HTMX is trying to solve. There is a strong developer instinct to "simplify through complexity". That is, to stuff down so much functionality and saw off all edges in an effort to hide complexity. "Let's expose a simple interface that will allow devs to do everything they want to do." It starts with good intenti…
Re: Ludic: New framework for Python with seamless Htmx support
#99I'm still a bit sceptical if this is the solution but I'm definitely going to look into it as it fixes a few things I'm annoyed with.
Thanks!
Re: Ludic: New framework for Python with seamless Htmx support
#100I don't know, every time I see people sneaking html into Python feels weird and wrong to me...
I remember coding PL/SQL to emmit HTML in Oracle around 1999 or 2000 and using functions to code the various elements.
That got old and repetitive very quickly - for instance, 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 functions 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 input matched the schema and could be rendered.
Or something like that - its been 2 employers and almost 20 years since I worked with that :)
I did build a small 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, but 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/