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

160
Vistas
Ejs include partials files not rendering

I am trying to use ejs in a node js project. I have managed to render the views file(.ejs') and use the .js data in it. and getting the desired webpage including the stylesheet. the problem occurs only while using partial After importing the header.ejs file in customer.ejs I am getting the exact text syntax of the header.ejs on the webpage. <%- include("partials/header") %> In short customer.ejs is locating the header file and importing the it fine. but not rendering it

Output

�� <�head> <�link rel="stylesheet" href="/css/style.css"> <�title>Customer<�/title> <�/head> 
Name: abc

my directories are as follows project\public\css\style.scc project\views\partials\header.ejs> project\views\customer.ejs project\app.js i am using Express my syntax are as follows

app.js

 app.use(express.static('public'));
 app.set('views', './views');
 app.set('view engine', "views");

customer.ejs

<html >
<%- include("partials/header") %> 
<body>
    <h1>
         Name: <%= customer.name %>
    </h1>   
    
 </body>
 </html>

header.ejs

<head>

    <link rel="stylesheet" href="/css/style.css">
    
    <title>Customer</title>
</head>

Things i tried

<%- include partials/header %> <%- include("partials/header") %> <%- include("./partials/header") %> <%- include("partials/header.ejs") %> and several more.. also tried using the express-partial module. also tried it on different browsers. Please let me know if i am doing something wrong or using a decrypted method Any help would be appreciated. Thank you.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I got the answer to my question after surfing google for a significant amount of time. Something went wrong with the Unicode After pasting the following in the root dir the problem was solved. Just after hitting enter, my entire app.js got changed to some Chinese text. but ctrl+z brought my code back.

Get-Content .\app.js -Encoding Unicode | Set-Content -Encoding UTF8 
.\app-fixed.js ; Move-Item -Path .\app-fixed.js -Destination .\app.js - 
Confirm -Force 
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