グローバルナビをjs無しでclass付けしてカレント(アクティブ)かどうかの制御がしたいのですが、効かなくて数日悩んでます。
例えば、 news.html内のincludeの「current」が'news'だった場合、
header.ejsの<li>の中にclass="active"をあてたいのですが、書き方が悪いのかそのまま
<% var ejsRoot = '../../'; %>
<%- include(ejsRoot + 'common/header', {current : 'news'}); %>
と書き出されてしまいます。
ejsが反映され、且つ<li class="nav active">になってるようにするにはどうすればいいでしょうか?
ejsが反映されないパターン
header.ejs
<li class="nav <% if(current == 'news'){ %>active<% } %>"><a href="news.html">news</a></li>
news.html
<% var ejsRoot = '../../'; %> <%- include(ejsRoot + 'common/header', {current : 'news'}); %>
ejsが反映されるパターン(if文なし)
header.ejs
<li class="nav "><a href="〇〇.html">〇〇</a></li>
〇〇.html
<% var ejsRoot = '../../'; %> <%- include(ejsRoot + 'common/header', {current : '〇〇'}); %>
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。