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

259
Views
include ejs with statement

I want to know if it's possible to include my header with ejs only if the user is loggin. I tried this:

<% if(connect) { %>
    <%- include('../partials/header-login'); %>
<%  } else { %>
    <%- include('../partials/header'); %>
<% } %>

Is someone having a solution ?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You are in the right track! From the docs:

Html template:

    <% if (user) { %>   <h2><%= user.name %></h2> <% } %>

Usage:

let template = ejs.compile(str, options);
template(data);
// => Rendered HTML string

ejs.render(str, data, options);
// => Rendered HTML string

ejs.renderFile(filename, data, options, function(err, str){
    // str => Rendered HTML string
});

You can see more detais on the oficial documentation: https://ejs.co/#docs

For better usage of the stackoverflow, you can fallow this guide: https://stackoverflow.com/help/how-to-ask

about 4 years ago · Juan Pablo Isaza 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!