It seems like a simple question, but I can't find anything about it in google or stackoverflow. Probably I haven't found the right keywords.
In php you can write something like this
example.php
<?php
//a bunch of sloppy logic, or maybe some includes but for this I'll just define the variables below...
$title = "Word to your mother";
$heading = "Too legit";
$paragraph = "Extensive research has shown that people's taste in music stops changing once they are forced to earn a living. Maybe that's when they learn how dumb the lyrics really are or maybe they don't have time to waste on things that no longer matter...";
?>
<!DOCTYPE html>
<html>
<head>
<title><?=$title?></title>
</head>
<body>
<h1><?=$heading?></h1>
<p><?=$paragraph?></p>
<h2>Counting</h2>
<?php
for($x=1;$x<=10;$x++){
?>
<p><?=$x?></p>
<?php
}
?>
</body>
</html>
Is there some equivalent of this in nodejs?
The broader question has something to do with serving dynamic content from a nodejs server that the browser sees as static. Solutions that require any kind of JavaScript on the client side will not work for me.
I saw ejs and vue but they both have something like <script src='source.js'> on the DOM which is exactly what I don't want and can't have.
If you think this is a duplicate, please say in the comments and give me a chance to clarify before marking it as a duplicate.
Clarification/Update:
The term "template" is probably a negative keyword for the functionality I'm trying to describe. In the php example above I could nest a html element inside of an if statement or loop while keeping the server markup inline. There's another post here where the question basically asked the same thing but the answer is not remotely satisfactory.