This post continues my previous post of sharing common tag elements to multiple Mustache Templates where we introduced the idea of a PageInfo class. In this post we'll focus on extending that logic to highlight navigation menu items like "Posts" in this image.
As described in the previous post we're using a simple Pageinfo.cvs file to store basic page data. The last item in the CVS records is a NAVBAR_MENU item where in the 3rd record you'll see "posts" and in the 5th, "admin."
While parsing our Pageinfo.cvs file we'll extract that value to build our PageInfo.ActiveMenu object.
Here's our getActiveMenu() method.
Using ActiveMenu in Mustache
Now we have an ActiveMenu element set to TRUE and can use it in Mustache.
With the happy result of a highlighted "Posts" menu element.