Giter Site home page Giter Site logo

HTMLX Support about j2html HOT 8 CLOSED

TareqK avatar TareqK commented on September 1, 2024
HTMLX Support

from j2html.

Comments (8)

TareqK avatar TareqK commented on September 1, 2024 2

Closing this, as i created j2htmx to extend for now

from j2html.

sembler avatar sembler commented on September 1, 2024

I've heard good things about htmx. To start I'd look at the Tag::attr methods to see if those meet your needs. They'll allow you to add any attribute you could want, without needing to extend any existing classes.

If you're interested in adding logic behind a Tag you could extend the ContainerTag or EmptyTag classes for whatever you need. It is also possible to create your own classes that provide custom rendering by implementing DomContent and the render(HtmlBuilder<T> builder, Object model) method.

from j2html.

TareqK avatar TareqK commented on September 1, 2024

Id love it if I can extend the base classes and make it part of j2html to boot

Edit : my original plan was to create new versions of each tag BTW, this would save me a lot of effort

from j2html.

sembler avatar sembler commented on September 1, 2024

I think it would need to be distributed as a separate Jar, and I'd expect there to be many changes under the hood as we progress towards version 2.0.

from j2html.

TareqK avatar TareqK commented on September 1, 2024

I Dont mind doing it like that, by extending each base class. But should this be in this repo or another repo?

Edit: Looking at this code base, I can probably use some regex magic and create 2 versions of the library, one with the HTMX tags(which are available for all container tags) and one without. Would that work?

from j2html.

sembler avatar sembler commented on September 1, 2024

My initial impression from the htmx docs is that this is heavily focused on getting the correct content for the correct attributes. To that end I'd suggest starting by defining small utilities to do that instead of worrying about deep integration with existing classes. Like Attribute put = HX.put("/messages") so that you can the use the attribute in J2html div().attr(HX.put("/messages")) to get <div hx-put="/messages"></div>. As you expand on that support class you could add features towards the specific syntax that HTMX recognizes like hx-trigger="mouseenter once". If you end up still pursuing integration with J2html you'll have all of those utilities ready to use behind the scenes.

from j2html.

TareqK avatar TareqK commented on September 1, 2024

I went ahead and did that https://github.com/TareqK/j2htmx

from j2html.

sembler avatar sembler commented on September 1, 2024

Thanks @TareqK ! This looks really nice. I like where you are going with your examples.

from j2html.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.