1<ul>
2 <% users.forEach(function(user){ %>
3 <%- include('user/show', {user: user}); %>
4 <% }); %>
5</ul>
1<div id="output"></div>
2<script src="ejs.min.js"></script>
3<script>
4 let people = ['geddy', 'neil', 'alex'],
5 html = ejs.render('<%= people.join(", "); %>', {people: people});
6 // With jQuery:
7 $('#output').html(html);
8 // Vanilla JS:
9 document.getElementById('output').innerHTML = html;
10</script>
1let str = "Hello <%= include('file', {person: 'John'}); %>",
2 fn = ejs.compile(str, {client: true});
3
4fn(data, null, function(path, d){ // include callback
5 // path -> 'file'
6 // d -> {person: 'John'}
7 // Put your code here
8 // Return the contents of file as a string
9}); // returns rendered string