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

164
Visualizações
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 Respostas
Responde à pergunta

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 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