4

Is there any emacs mode that can format properly the ejs template file.

Sample EJS template file

<!DOCTYPE html>
<html>
  <head>
  </head>
  <body>
    <b> <%= doc.session_name %> </b>
    <ul>
      <% var p = {}; %>
      <% var coinInitialPositions = [-1, -1]; %>
      <% for (var i = 0; i < doc.moves.length; ++i) { %>
     <% if (doc.moves[i].type === 'dice_values') { %>
     <%     if (typeof p[doc.moves[i].player] === 'undefined') { %>
         <%        p[doc.moves[i].player] = []; %>
         <%     } %>
     <%     p[doc.moves[i].player] = p[doc.moves[i].player].concat(doc.moves[i].values); %>
     <% } %>

     <li>
        <%= i + " " + JSON.stringify(doc.moves[i]) %>
     </li>
      <% } %>
    </ul>
    <% for (var player in p) { %>
    <li>
      <b> <%= player + ": [" + p[player] + "]"%> </b>
    <li>
      <% } %>
    </body>
</head>
Naeem Shaikh
  • 15,331
  • 6
  • 50
  • 88
Talespin_Kit
  • 20,830
  • 29
  • 89
  • 135

1 Answers1

3

You should look at web-mode.el which has very good compatibility with ejs

fxbois
  • 806
  • 9
  • 21