As we have experienced, generating HTML within a node.js/Express server can be painful. Remember from our previous technical tutorial, data we send back using the response.send
function needs to be a string. If we want any type of HTML formatting, we need to create it ourselves inside of the string.
app.get('/', function(request, response) {
response.send("<h1>This is a simple response</h1>")
})
This can get really tedious really quickly. Enter templating systems.
ejs
(Embedded Javascript) Templatesif
statementsfor
loops