So I have been fine adding a home button to the rest of my pages on my app. I want to add a title that goes with each page, but keep the home button code compartmentalized.
I thought it might be possible to send variables through using the include notation, but it is not working. I know my file system is correct, because when I take out the second argument to the include function, everything works fine.
This is the current code in where I want to have the home button, with a custom passable title.
<%- include("../partials/homeButton.ejs", { title: "page title" });%>
And the code I have in homeButton.ejs is simply
<% if(typeof(title) === 'undefined') title = "no title included" %>
<h1 id="homeButton" class="hover-underline montserrat-medium fs-2rem"><%= title %></h1>
It is simply not recognizing the title variable as a thing. It says title is undefined, and because of my if statement in homeButton.ejs, it always displays, "no title included".
page title
` as my html. Can you paste how you are rendering the ejs? – Aritra Chakraborty Jul 31 '19 at 18:05