1let express = require('express');
2let app = express();
3
4app.set('view engine', 'ejs');
5
6app.get('/', (req, res) => {
7 res.render('index', {foo: 'FOO'});
8});
9
10app.listen(4000, () => console.log('Example app listening on port 4000!'));
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>