passing function to ejs partial

1050 views node.js
6

I appologize if this is asked before but I couldn't find this question.

Basically i am trying to pass data into EJS partial the data has a function that I want to pass to partial but apparently it does not seems to work. Here is example.

<html>
<head>
    <title><%- title %></title>
</head>
<body>
    <%- include ('partials/header',{myFunction}) %> 
    <div id="content">
          <%- content %>
    </div>
    <% include partials/footer %>
</body>

I have also tried using ES5 object literal syntax to pass function but it still throws me error that says

Error: Could not find the include file "(&#39;partials/header&#39;,{myFunction})"

I really appreciate if someone can pinpoint what am I doing wrong here.

Thanks!

answered question

1 Answer

12

I have figured out. It was a silly mistake. I had to remove whitespace where it says include ('partials/header',{myFunction})

posted this

Have an answer?

JD

Please login first before posting an answer.