Passing Variable with EJS Templating

前端 未结 1 317
太阳男子
太阳男子 2021-01-18 05:25

I am using the Ejs templating engine for my expressjs project and despite passing my objects along to my view blog.ejs file, I am receiving an blogpost not defined

相关标签:
1条回答
  • 2021-01-18 06:09

    You're not passing an array variable called blogpost to your template, you are instead passing these variables to your template:

    title: blogpost.title,
    author: blogpost.author,
    content: blogpost.content,
    date: blogpost.date
    

    You could just do this render() instead of the one you currently have:

    res.render('pages/blog', {
      blogpost: blogpost,
    });
    
    0 讨论(0)
提交回复
热议问题