I usually put directly in the template: <% if (current_route 'foo') {
%>...<% } %>This works as long as you make sure your routes have useful names, you can apply names manually at the end of a route definition. https://metacpan.org/pod/Mojolicious::Guides::Routing#Named-routes -Dan On Tue, Mar 13, 2018 at 1:28 PM, Viktor Nacht <[email protected]> wrote: > I'm sure this is common issue that can be solved in many ways, I just > wanted to make sure I wasn't totally missing the Mojo way to do it. :) > > I have a navigation area, say pages A, B, C. When on page B, I want to add > a CSS class to the a tag to highlight the current page. > > The 2 ways that spring to mind is using JS, and my current solution, store > the links in an array of hashes in the Config plugin and then use a partial > template to process those into the navigation html, matching the current > route to add the class. > > Am I missing any other obvious solutions? I could probably also use a > helper. So may options, haha. :) > > Thanks! > > V > > -- > You received this message because you are subscribed to the Google Groups > "Mojolicious" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/mojolicious. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Mojolicious" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/mojolicious. For more options, visit https://groups.google.com/d/optout.
