<% include ./layout/header %>
<style type="text/css">
.centeredText {
text-align: center;
}
</style>
<% include ./layout/footer%>
If I do a readfile on this, then I try to render the stream with EJS, it tells me "error: filename option is required for includes"; but if I simply render the template in express it works fine. Why is it ? I understand the "readfile" only takes the contents so it doesn't include the other files, but why doesn't EJS do the includes once I try to render ? How should I do it ?
Of course, because I give only file contents to EJS, it can't know where they come from and so it can't know where to go for the includes. Had to specify a filename parameter in the datas with the name of the template. Works fine
Because right syntax is
<%- include('{{file_name}}'); %>