179
rated 0 times
[
182]
[
3]
/ answers: 1 / hits: 20856
/ 7 Years ago, wed, february 1, 2017, 12:00:00
I am new to using ejs. I have a menu and I want to highlight the current menu item.
I have tried this:
<li class=<% currentMenu == 'dashboard' ? 'active' : ''%>>
<a href= '/dashboard'>
<i class=material-icons>dashboard</i>
<span>Dashboard</span>
</a>
</li>
The value of the currentMenu is served by an express router as shown below:
app.get('/dashboard', function(req, res) {
if (isAuthorised) {
res.render('pages/index', {
title: 'Welcome | MW Tracker',
email, userName, role, menus,
currentMenu: 'dashboard'
})
} else {
res.render('pages/sign-in', {
title: 'Sign In | MW Tracker'
})
}
});
Please how am I suppose to add the class?
More From » node.js