So I am making an Express.js (node) app, which is passing a variable to the templating engine (ejs). Then the variable is loaded as a
element in a div. The problem is, that when the variable expands, I want it to separate the new string into a new line. Also, I want delete old elements, so they don't expand out of the div. It would look like a simple console.
Nodejs
app.get('/console', (req, res) => {
currentMessage = currentMessage + `Console log`;
res.render('console.ejs', {currentMessage});
});
.console {
background-color: black;
width: 80%;
margin: auto;
height: 30%;
border-radius: 10px;
padding: 10px;
text-align: start;
}
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" type="text/css" href="style.css"/>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div class="console">
<p style="color: white;"><%= currentMessage %></p>
</div>
</body>
</html>
Thanks for taking your time!