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

127
Visualizações
Issue convert jade to handlebars

I am trying to rewrite some code that was written in jade. I need to use express-handlebars or something else that does not entirely alter the structure of html file. My question is: how to pass parameters in the new version, for example, the following one which is user?

The old working version using jade:

app.js

var router = require('express').Router();
router.get('/', function(req, res) {
  res.render('index', {user: req.user});
});

index.jade

block content
  if (user)
    p You are currently logged in as #{user.username}
  else
    p You are currently not logged in. Please login or register...



The new version using handlebars:

index.handlebars

<div class="content"></div>


So what should I write in the new index.handlebars file and/or what to change in app.js in order to display the user.username correctly? I am quite new to this so I appreciate anything that helps.

#Updates#

index.handlebars

<a href="/login">Log In</a>

app.js

var router = require('express').Router();
router.get('/login', function(req, res) {
  res.render('login', {user: req.user});
});

This <a> link worked in previous index.jade file which was written as

a(href="/login") Log In

Why it is not working in the new index.handlebars file? (More specifically, the url changed to localhost:123/login but the content does not change. No error in console.)

about 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

0

I am not sure, but try this

index.handlebars

 <div class="content>

     {{#if user}} 
         <p>You are currently logged in as {{username}}</p>
     {{else}}
         <p>You are currently not logged in. Please login or register...</p>
     {{/if}}


 </div>
about 4 years ago · Santiago Trujillo 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