Passing variables to Jade templates with Express 3.0

I’ve just updated Parkuik with express 3.0 and found some problems (here).

Following that guide is easier, but as always, let’s do this as a reminder or just to keep updated all of you.

The line you must read to migrate from 2.x to 3.0 is this:

Removed
- app.dynamicHelpers() (use middleware + res.locals)

So, you have to use a middleware in order to use variables passed from server to use them on jade templates.

Just as an example you can do:

Now, in jade templates you could use that as variables. If user is authenticated you can start using its data to make ajax request or just to show it’s username (whatever you want!)

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>