Search code examples
node.jsexpressejs

Options in res.render can only give 1 variable


I have a problem with the res.render in express who render a ejs view, if I try this :

res.render('index');

I don't have any problems, also if I do

res.render('index', {foo:"bar"});

I still don't have any problems but if I do

res.render('index', {foo:"bar", bar:"foo"});

all my vars will not be defined so someone have an idea how can fix this?


Solution

  • I now have a little more experience and I can just do:

    res.locals.foo = "bar";
    res.locals.bar = "foo";
    res.render("index");