How to load multiple routes in Node.js in a . jade

Asked

Viewed 89 times

0

Is there any way to load multiple routes within the same file .jade, for example:
I may have a route /menu, another /header, another /clientes, when calling the route /clientes give a res.render('clientes') and call all three in one file, like:

html
  body
    [Inclui a rota /header]
    [Inclui a rota /menu]
    [faz a lógica da tela de clientes]

1 answer

0

An example with 2 files:

File layout.pug:

html
  head
    title O meu site
    // etc...
  body
    block bodyPagina

File contactos.pug

extends ./layout.pug

block bodyPagina // aqui continuas o conteúdo do body definido no layout
  h1 Olá mundo!
  p Hoje está um lindo dia!

The file to be called by express on res.render should always be the most specific page, in this case the contactos.pug.


Note: I’m using the extension .pug for Jade was replaced by Pug.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.