aboutsummaryrefslogtreecommitdiff
path: root/tools/blog/node_modules/ejs/examples/client.html
blob: 51ce0b4ced570c1e96c8c2ea7fd02056398cc16d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
<html>
  <head>
    <script src="../ejs.js"></script>
    <script id="users" type="text/template">
      <% if (names.length) { %>
        <ul>
          <% names.forEach(function(name){ %>
            <li><%= name %></li>
          <% }) %>
        </ul>
      <% } %>
    </script>
    <script>
      onload = function(){
        var users = document.getElementById('users').innerHTML;
        var names = ['loki', 'tobi', 'jane'];
        var html = require('ejs').render(users, { names: names });
        document.body.innerHTML = html;
      }
    </script>
  </head>
  <body>
  </body>
</html>