Answer the question
In order to leave comments, you need to log in
How is data output through the ejs engine to the view?
Please tell me ejs.render(str, data, options); where str is the name of the view, maybe the page name is more precise? How is data displayed in the view using this template engine? I read the official information, but there str is the output of some construction, but how can I specify that it be output to a certain representation? Pure Node.js
Answer the question
In order to leave comments, you need to log in
A template engine is just a lib that substitutes the values passed to it into the template. It has nothing to do with presentation. The template engine simply gives html ready for output to the page. And what to do next with the output is up to the developer.
I myself have no idea how it works natively, I always used it through express, but it is obvious that it returns the result and then it is given through the web server, while it can cache templates. And str may well be necessary to first read from the file and give it to the cache function.
var template = ejs.compile(str, options);
template(data);
// => Rendered HTML string
ejs.render(str, data, options);
// => Rendered HTML string
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question