How to pass a variable to a ejs layout?

Viewed 184

I have been wanting to pass an ejs variable to a layout file. I have figured out one way but it takes a lot of time and some space. I have tried to pass the same variable to each file that is being rendered, but since I am using routers, it is a bit of a problem for me. I need to write the variable in each file and pass the ejs parameter. Since I want to pass multiple parameters, it is really stressful. here is my code:


const productiono = process.env.NODE_ENV /* name productiono to avoid conflicting with ejs it's variable which I am naming production. */

router.get('/register', async (req, res) => {
    console.log("Signup process initialized")
    await res.render('signUp', { production: productiono })
})

if anybody can help it would be very much appreciated,

Kamestart

0 Answers
Related