Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

122
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!