include ejs template

My view directory there is a head.html and foot.html as well as a catalog article, there is a file in a showarticle.html article directory, the file I want to include outside head.html and foot.html, but each time include all in my newspaper article directory include file not found

On showarticle.html write
<include "... / head.html">

Faced with this problem, there is the Internet to find the next sibling gives a solution: http: // Solution is as follows :
1. analyzing resolveInclude file path by which method ejs source;
2. modify this method:
function resolveInclude (name, filename, Options) {
  var path = the Join (options.settings.views, name );
  var EXT = extname is used (name);
  IF (EXT) + = path '.ejs';!
  return path;
and root path through the opposite view to find
3. modify its local call, passing options.

ejs inlude changes
just in time with the blog node development system encountered a place ejs inconvenient. I want to file two views of users and articles on the respective folder, for example, after a user / user.ejs, post / post.ejs complete change, then ejs of inlude comon / page.ejs, this line on the error , the path can not be found /views/post/common/page.ejs see I understand, the original ejs do is include the file contained, then it seems to go back and change it, but I do not want to change, I want classified document management, so we must change inlude the operation ejs. So I tracked and found ejs there is a method to manipulate the path inlude problems. resolveInclude (name, filename) Yes, it is this method, which has a key code to join (filename, name); This line is the current file path + back inlude string, but I hope that is based on views as with path, others are referring to this path inlude so I thought that since there are express views set path, ejs should get, and I went to see the render method, the render method which has a magical thing options. So, I put options to print out and sure enough, there are options a path of views, it is simple to change under the join (filename, name); resolved ok, the problem, then I; to join (options.settings.views, name) All views include paths are relative to the views of the inside of the path I'm free to include.

Guess you like