Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

196
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda