Re:Django, HTMX and Alpine.js: Modern websites, JavaScript o...
by simion314 on Tuesday November 23, 2021 @12:22PM
(#29320441)
>you have to start from the beginning and write an API now.
You could refactor your code to share mostly everything .
I have no idea how this templates system work though so maybe you need a different one.
so the API returns an array of users object as a json
the html side of things would have a render function that has as input the same array of user objects. What you will probably lose versus complex frameworks is magic stuff like 2 way data bindings but from my experience those always caused issue, I prefered the old react way of doing things, it was more "functional style" and less magic under the hood and I could(and used) JS and not a special template language with special keywords to render stuff.
Amway my point is yu can reuse the API code for the html render stuff too.
You could refactor your code to share mostly everything . I have no idea how this templates system work though so maybe you need a different one.
so the API returns an array of users object as a json the html side of things would have a render function that has as input the same array of user objects. What you will probably lose versus complex frameworks is magic stuff like 2 way data bindings but from my experience those always caused issue, I prefered the old react way of doing things, it was more "functional style" and less magic under the hood and I could(and used) JS and not a special template language with special keywords to render stuff.
Amway my point is yu can reuse the API code for the html render stuff too.