question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

include not a function error

See original GitHub issue

Hi,

I am positive that the above error is caused by my implementation or use of ejs, but I have a scenario where I am trying to render a partial within a partial, this particular section of the view gets rendered after an Ajax call (I’m trying to split my views into smaller components)

I have a view file views/home.ejs and within that I have <%- include('test-component') %>

The error I get is include is not a function

When sending the rendered html back to the client it is compiled through

const readAndCompileFile = async filePath => {
  const file = await readFile(filePath);
  return ejs.compile(file, { client: true });
};

const sendHtml = async (data, res) => {
  const template = await readAndCompileFile(TEMPLATE_FILE_PATH);
  const html = template({ ...data, Utilities, moment });
  return res.send({ html });
};

I hope this is enough information but if anything further is needed then please advise

I am on the latest version of ejs, 3.1.3

Thank You

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
eyupahmetyilmazcommented, Nov 25, 2021
const readAndCompileFile = async filePath => {
  const file = await readFile(filePath);
  return ejs.compile(file, { r_client: true });
};

If you using “include” in .ejs file, don’t use client

1reaction
woodscreativecommented, Jul 26, 2020

Using EJS 3.1.3 with Express 4.17.1 and cannot get includes to work either include not a function without async.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Using .includes method in a function - javascript - Stack Overflow
includes () API is part of the String and Array data type. So what the error is trying to tell you is that...
Read more >
TypeError: includes is not a function in JavaScript | bobbyhadz
The "includes is not a function" error occurs when the includes() method is called on a value that is not of type string...
Read more >
How to solve includes is not a function in JavaScript - Reactgo
The “includes is not a function” error occurs when we call a includes() method on a value other than the strings or arrays....
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript error TypeError: "x" is not a function occurs when there is an attempt to call a function on a value or...
Read more >
".includes is not a function" for arrays of unquoted integers
See the above example. For the unquoted array, I get "TypeError: x.includes is not a function" in Firefox and Chrome. Why could it...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found