I've got some node js code which is responsible for creating a function, that I want to execute in my .pug template.
let pages = [
{
"id": 0,
"name": "Index"
},
{
"id": 1,
"name": "About"
},
{
"id": 2,
"name": "Kontakt"
},
];
function navigation(pages) {
return pages;
}
app.get("/", (req, res) => {
res.write(navigation(pages));
res.render("index");
});
How can I call for this function in the pug template or what is a better way to pass a function from node to jade?