I\'m starting with node in general, and I\'m attempting to do a site without express. I would none the less want to use ejs to inject my html and this is where my problem is...
Example from some book: template.ejs
<% entries.map(entry => { %>
<%= entry.title %>
<%= entry.date %>
<%= entry.body %>
<% }); %>
function blogPage(entries) {
const values = { entries };
const template = fs.readFileSync('./template.ejs', 'utf8');
return ejs.render(template, values);
}
const server = http.createServer((req, res) => {
const entries = getEntries();
const output = blogPage(entries);
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(output);
console.log('run server');
});
server.listen(8000);