Search code examples
ejsexpress-4

EJS - Scripts in wrong location


In the interest of DRY, I have 3 page types in my SPA: (1)Layout, (2)Index, and (3)XXXX (view). Layout has the body related tags, Index the nav system, and XXXX the relative content. Here is the code:

Layout.ejs:

<!DOCTYPE> 
<html> 
<head>
<title>Index Page</title>
<% include ../includes/styles%>
<script type="text/javascript" src="/vendor/jquery/dist/jquery.min.js" ></script> 
</head>
 <body>
</body>
<% include ../includes/scripts%> 
</html>

Index.ejs:

<% include ../includes/layout %>
<h1>This is where the nav bar goes</h1>
<div data-ng-view></div>

View pages not important for this problem. What I noticed is that my sccript tags from layout are above the body's children DOMs, not at all what I wanted. What I wanted is:

----- body

   --- content    

----- scripts

What must I do in layout.ejs to keep the script tags at the bottom of the final html page?


Solution

  • ejs-locals does not support Express 4.x.

    I opted for creating a custom engine.