I am currently trying to develop a partial templating file for a navbar using ejs, however I am struggling to add additional classes to an element which already has classes added to it.
I have tried 2 methods of adding the additional class, this is the first one:
<li class='navbar-item'<% if (pageTitle === 'Home') { %> class="active" <% } %>> <a href="/home">Home</a></li>
However this did not work so I decided to try embedding the EJS inside the class attribute, as follows
<li class="nav-item <% if (pageTitle === 'Home') { %> active <% } %>">
This also did not work, I have ensured that pageTitle is being served correctly as it is used elsewhere within the webpage and works fine.
I am not sure as to what the next stage is, I have considered using an additional JS file but that seems counter productive as I already have the ability to embed the JS inside the HTML.
Any help is appreciated, thanks in advance.