Fork me on GitHub
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. 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

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


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:

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" who cover authentication, etc in Clojure / ClojureScript which I will put online soon. Do not hesitate if you have other questions and stay tuned. 😉


> (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:


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