Crinja/ECR and Template Fragments/Partials (htmx, web dev)

For Jinja2 there’s a plugin jinja2-fragments which I presume provides what you want.
It should work in a pretty similar manner for crinja as well: rendering individual block fragments. Only caveat is that crinja currently doesn’t expose a public API for this. It could work by creating a custom Crinja::Renderer instance, using that to render the template once. Then you have all blocks available in Render#blocks and can render each one individually as required.

1 Like

In case anyone in interested, PECR should be in a usable state now.

2 Likes

Got thinking while walking the dogs, and came to think of Storybooks popularity in the JS world. One could duplicate that by having a separate little program (or multiple) that feeds some example data to the ECR and serves it over HTTP. Which is basically the core thing that Storybook does. Coupled with filewatching and hot reload, this might be acceptable (not mentioning the advantage of decoupling the frontend development).

Use lucky component for this purpose is not a bad idea. (you can purpose a apple M4 processor for shorter compile timer, :smile:

Anyway, if you prefer, you can create all fragements(that is, component here) directly in the view file instead, don’t need split to little file, right? then render it in controller(action) directly use component(ComponentName) instead or mount(ComponnetName) in the view.