Making functions available in ejs files
Its a very common usecase where you want to make some functions available to your ejs files. Following code shows you how to make that possible.
In the following example we are adding a function square
which takes a number and return the square value for that number. We will use this function in ejs file.
At index.js file
function square(inp){
return (inp * inp);
}
At foo.ejs file
<p> <%=square(5)%> </p>