Home > Software engineering >  Pug not rendering variables defined in res.render
Pug not rendering variables defined in res.render

Time:10-02

Does anybody know why my tour variable is not rendered on the site. My paragraph is rendered but tour is undefined

app.get('/', (req, res) => {
  res.status(200).render('base', {
    tour: 'The Forest Hiker',
    user: 'Eldin',
  });
});
(base.pug file)
doctype html
html
  head  
    title Natours
    link(rel='stylesheet' href='css/style.css')
    link(rel='shortcut icon' type='image/png' href='img/logo.png')

  body
    h1= tour
    p This is just some text

CodePudding user response:

The = behind the H1 is not correct.

Use:

body
    h1 tour
    p This is just some text

CodePudding user response:

I found the answer. It should be used #{tour}

  • Related