Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

195
Visualizações
Pass an include parameter in Pug template from ExpressJS?

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 !

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

Please ensure you are using:

app.set('view engine', 'pug')

Also, dynamic import is not allowed yet, so your include can't be variables

about 4 years ago · Juan Pablo Isaza Relatório

0

Since the pageContent is being passed in via the render function, should this be:

html
  head 
    include includes/head.html
    title= title
  body
    include includes/header.html
    #{pageContent}
    include includes/footer.html
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda