Fork me on GitHub
#releases
<
2021-05-18
>
Michaël Salihi20:05:05

New release of Inertia-clojure v0.2.1, Clojure middleware for Inertia.js to build single-page apps, without building an API. https://github.com/prestancedesign/inertia-clojure This version supports History.pushState (query-string appended to URI), so the app state is loaded/restored even after direct access to a URL Props are now optional via multi-arity render function. Some demo examples updated

👏 6
tvaughan20:05:38

Is it possible to use different templates for different routes?

Michaël Salihi21:05:58

No, this has not been necessary at the moment. Can you specify for which case you would like to have this possibility? Thx

tvaughan21:05:01

Signed in versus signed out? If the user isn't signed in, redirect her to sign in. Once signed in, redirect her to the dashboard. Different templates for public and protected content?

Michaël Salihi15:05:12

Oh yes of course, it's possible...this is even the core of Inertia. All the logic (routing, sign in -> auth -> redirect, etc) remains managed by the back end. Then handlers returning Inertia reponses take a front-end template (for each routes) in second arg: (inertia/render :the-template-name props)

Michaël Salihi15:05:27

In fact, it is more of a component than a template. This is then used in the front end (whether with CLJS Reagent, etc or JS React, Vue) with the same component name with with the props passed in 3rd argument. See: https://github.com/prestancedesign/reagent-inertia-reitit-integrant-fullstack/blob/main/front/src/reagent/inertia.cljs#L31

Michaël Salihi15:05:35

Hope this is more clear. I am planning more documentation, and tutorial and I am currently making the official Inertia demo "PingCRM" http://demo.inertiajs.com who cover authentication, etc in Clojure / ClojureScript which I will put online soon. Do not hesitate if you have other questions and stay tuned. 😉

tvaughan15:05:39

> (inertia/render :the-template-name props) Ah ok. I didn't know the keyword meant template name. The example has just one template, (inertia/wrap-inertia routes template asset-version), and both routes have a different keyword but pass a map with a :title key which is in the one template passed to inertia/wrap-inertia

Michaël Salihi16:05:46

> I didn't know the keyword meant template name. Yes, I must to add docstring too for more clarity.

Michaël Salihi16:05:22

Indeed, the template passed to the wrap-inertia middleware is the "root template". It is the container with the js, css, meta, etc. scripts as well as the <div id="app" data-page="JSON object props" on which the front end components will be hooked. Check: https://inertiajs.com/server-side-setup#root-template

tvaughan21:05:24

Thanks for taking the time to explain this to me and for providing these links