Twack icon indicating copy to clipboard operation
Twack copied to clipboard

Feature-Request: HTMX output of components - Optional partial output of a page

Open spoetnik opened this issue 2 years ago • 4 comments

I am looking for a way to output template-parts for returning html for the HTMX framework. 'With Twack, an alternative Ajax view can be created.' How hard would it be, and how would you go about, building a HTMX-api?

Something like calling /htmxapi/component?parameters, and then have it return html to be parsed with HTMX?

spoetnik avatar Jan 28 '24 19:01 spoetnik

Hi @spoetnik Thank you for your input! I do not have any experience with HTMX, but I guess what you need is outputting a different format when requested? I already have the ajax (JSON) output switch in place, which checks whether its an api call or a classic page call where HTML should be returned. But it could be worth a thought to make components able to respond correctly to different content type requests. Would HTMX output look like "normal" HTML with special attributes, or is it a totally other format?

Sebiworld avatar Feb 03 '24 18:02 Sebiworld

HTMX returns just the HTML to replace a part of the DOM. So not the whole page, bust just parts. The htmx library inserts that into the DOM. It would be nice to have a way to just return the HTML of a component. As Twack uses components, and has some interface with an API-layer I thought maybe this would be a great start?

Maybe this could better be a brainstorm in the forum? Or is Github the best place?

spoetnik avatar Feb 03 '24 19:02 spoetnik

You are right, maybe it is better to discuss this further in the forum. Since it's your question - do you mind to post the question there again and mention me? I will leave this issue open so I have something where future commits can be linked to.

Sebiworld avatar Feb 04 '24 12:02 Sebiworld

https://processwire.com/talk/topic/23549-twack/?do=findComment&comment=238996

spoetnik avatar Feb 04 '24 20:02 spoetnik