Thursday 15 February 2018

How do I write functions in ejs?

hey,I have my project working with express. My route is set to: router.get('/', function(req, res, next) { res.render('index', { title: 'Test', test: test }); });Test are some data from my db. Now I want to add: <% test.forEach((test) => { %> How do I write the function showContent, so that it works? If I use and so on it will throw an error. I tried to import another EJS file where the function was written with no success. Neither did another JS file work.Can you help me?

Submitted February 15, 2018 at 09:35AM by oppoi <% }); %><% function showContent() { %>
<%= test.id %> <%= test.name %>

No comments:

Post a Comment