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

117
Visualizações
Pug - unable to get past step 1 of a boilerplate

total noob question but I cannot find any solutions to this sorry so last resort is to ask here.

I am trying to learn pug. Have created a boilerplate project and unable to render index page. Ive searched and read as much as I can but all I get is 'Error parsing body of the with expression' error. The index.js looks as simple as follows but stopping me in my tracks:

var express = require('express');
var router = express.Router();

// GET home page. 
router.get('/', (req, res) => {
  res.render('index', { title: 'Express' });
});

module.exports = router;

if anyone can provide a one liner to point me in the right direction to resolve this and keep rolling on my pug and nodejs journey I'd really appreciate it. Pug is appearing very difficult at this stage despite all the raving about it :/

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

0

I have checked one of my old projects. You can try something like this:

Install pug:

$ npm install pug --save

Then set up the app:

const express = require('express')
const app = express()
const port = 3000

// you don’t have to specify the engine or load the template engine module in your app; 
// Express loads the module internally, as shown below (for the above example).

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

// views, the directory where the template files are located
// This defaults to the views directory in the application root directory.

app.set('views', './views')


app.get('/', (req, res) => {
  res.render('index', { title: 'Hey', message: 'Hello there!' })
})

app.listen(port, () => {
  console.log(`Example app listening on port ${port}`)
})

Example pug file:

html
  head
    title= title
  body
    h1= message

Using template engines

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