4 ms·
You only need partials for shared templates instead of multiple per action on a single page.
by nprateem 3y ago
You only need partials for shared templates instead of multiple per action on a single page.
- naasking 3y agoYou don't need any partials at all, so this objection just doesn't apply. The server can return full pages and only parts of it are updated.
- viraptor 3y agoSorry, I don't get it. If you have client side rendering, you need a template for every thing you want to replace, at whatever level you choose (from full page to single element). If you do htmx, you do the same - provide a template for each replaceable part (from full page to single element). In each case, it's your choice how granular you want the updates to be - it can be one per action, or just rerendering the whole page. Why do you think the client side requires fewer partials, if you use the same scope of data changes?
- brabel 3y agoWith HTMX you shouldn't have a "template" per action. Most actions work on some "entity", and the "entity"'s page should be returned by the action, as it's very common for an action that change one bit of the "entity" to affect more than one part of the "entity" rendering. So you don't need one template per action, you need one template per entity, and different actions may replace the same entity. This is almost exactly what you would do in React, with "entities" being "components". I've designed a HTMX app this way and actually called the "templates" components. Each component is either a function or an actual (Kotlin) class with a render method. I can test the components in isolation, just like you can with JS frameworks, but all code is on the server - despite the app itself feeling just as reactive as any JS framework-based app.