Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

260
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda