Roda ERB active menu helper #349
teamschlaflos
started this conversation in
General
Replies: 2 comments 1 reply
-
Use |
Beta Was this translation helpful? Give feedback.
0 replies
-
Thanks, that worked! I couldn't make out the correct plugin (plugin list). Here is the updated version which works for me, without the plugin: <a class="nav-link <%= active_if "/section/item1" %>">Item 1</a>
<a class="nav-link <%= active_if "/section/item2" %>">Item 2</a> class App
# ..
def active_if(path)
if request.matched_path.start_with?(path)
'active'
else
''
end
end
end |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I'd like to create a menu helper function for my ERB templates. My initial thought was to have a menu variable for each route, but then I thought maybe I'd like to avoid to pollute roda route code with that information, but rather keep the decision in an ERB template:
The issue I'm having is that I'm unable to access
r
in the function:Can I somehow access
r
and does anyone have a nice way to handle menus or submenus in an app?Beta Was this translation helpful? Give feedback.
All reactions