I wonder how I can insert JS functions into an EJS file?
I have this function:enter image description here
I tried to create a separate .ejs file where I will insert a function between the tags <% %> and also import it into the ЕЈS file that I need, but it doesn't work for me
CodePudding user response:
EJS does not provide a DOM. Output from EJS is generated using <%=
and similar.
The document
object is only (that's a slight simplification) available in JS running in an HTML document in the browser.
To use that code you would need to include it in a <script>
element output from the EJS into an HTML document and run in a browser.