I'm new to Pug and ExpressJS and can't figure out how to do a simple thing: passing a template path from Express to Pug.
Here's an example of what I have in mind, with the variable named pageContent
:
./app.js
app.get('/', function (req, res) {
res.render('index', {title: 'Some Title', pageContent: 'includes/somePage.html'})
})
./views/index.pug
html
head
include includes/head.html
title= title
body
include includes/header.html
include #{pageContent}
include includes/footer.html
Any idea what I am missing ? Thank in advance for your help !
CodePudding user response:
Please ensure you are using:
app.set('view engine', 'pug')
Also, dynamic import is not allowed yet, so your include can't be variables