While working with a dynamic approach to loading views and includes I ran into two very annoying issues.
The first being that the EJS template doesn't support using variables as path names so you can not specify a view or include name in the route function and then add this to a path of the include. To solve this I used the file system to read the include then pass in a chunk of HTML to the main view as you would any other variable.
The second issue I faced came from human error rather than a short fall of the EJS template system. The includes that were being read and inserted into the main view were not being rendered as HTML. This frustrated me for a while until I realised that I was escaping the content.
This escapes content:
<%= variable %>
This doesn't escape content:
<%- variable %>