ExpressJS & Swig: Changing template variables based on route? ExpressJS & Swig: Changing template variables based on route? express express

ExpressJS & Swig: Changing template variables based on route?


When you use:

req.app.locals

It changes all the values for the app for everyone (until server restart). The proper way is to use:

res.app.locals

BUT when you do, it only does it for the initial page request and doesn't persist when the hash change is applied on the client side.

The recommended approach would be to create a new server layout file with the URL in question so there is no hash change, then perhaps your navigation for the new server template file can link back to the URLs in you one-page app (with the original server template).

Best of luck. 😀