News for hackers. Stuff that matters.
Re:Htmx – high power tools for HTML by nogabebop23 on Thursday May 28, 2020 @09:43AM (#23337108)
THat's how you negotiate the content type; the original question was how they have a service returning json return html. I've never heard of a framework that can arbitrarily convert data into HTML - how would that even work?
Re:Htmx – high power tools for HTML by capableweb on Thursday May 28, 2020 @01:05PM (#23339699)
I was part of a project that when I just joined it, RESTful APIs together with fat frontend clients was becoming the hot-new-thing. The application was originally returning text/html (templates) to be injected in various part of the frontend, at request-time.

To migrate to our flashy new Angular V1 application, we added a application/json content-type that instead of returning the template, returned the data that the template used. So we could endpoint-by-endpoint migrate to the SPA we were building.

Was simply a matter of making the data required for the views a bit more advertised internally, so the controllers could instead not render the views when the content-type is json.

Re:Htmx – high power tools for HTML by pseudosavant on Thursday May 28, 2020 @12:16PM (#23339039)
You could dynamically create HTML that mirrored a JSON response. You'd just have to have to walk the JSON structure and create a structure for where the key and the value from the JSON end up. Each node could just be a <div>. The ID could be a composition of the key and the parent nodes/keys so that it'd be unique. You could also stuff both values in a data-* attribute.

It wouldn't be the prettiest HTML but you could work with it via CSS and JS.