I want to create an app using NodeJS, Express and Pug. The app should work similar to an editor and react to different user events.
Now I have a conceptual question: Is the approach with NodeJS and a template engine right for this?
I stumble upon how to get the events into the template engine. In pug, for example, I can embed Javascript, but template engines do not seem to be made to implement user events - because in the documentation as well as here on Stack Overflow I don't find a "standard solution" for embedding JS scripts, at best workarounds and embedding JS directly in pug (not the reference to a script). For example here: render inline Javascript with jade/pug
I also tried to include a script myself:
Pug file
doctype html
html
head
title= `${title}
body
h1 My new App
block content
script(src="myscript.js").
JS Script
window.alert("Bingo!");
Html-Result
<!DOCTYPE html>
<html>
<head>
<title>Title</title>
</head>
<body>
<h1>My new App</h1>
</body>
<script src="myscript"></script>
</html>
The code seems to be correct, but it does not work.
So do I understand that template engines are not the right approach to implement user events? If this is correct, is client-only Javascript the better approach?