Module: NeonSakura::NavbarHelper
- Defined in:
- app/helpers/neon_sakura/navbar_helper.rb
Instance Method Summary collapse
-
#eval_nav_condition(condition) ⇒ Boolean
Safely evaluate a condition string in the current context.
-
#nav_icon_exists?(icon_name) ⇒ Boolean
Check if an icon exists before rendering.
-
#nav_link_active?(link) ⇒ Boolean
Check if a navigation link is currently active.
Instance Method Details
#eval_nav_condition(condition) ⇒ Boolean
Safely evaluate a condition string in the current context
25 26 27 28 29 30 31 32 |
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 25 def eval_nav_condition(condition) return true if condition.nil? || condition.empty? instance_eval(condition.to_s) rescue StandardError => e Rails.logger.warn("Failed to evaluate navbar condition '#{condition}': #{e.}") false end |
#nav_icon_exists?(icon_name) ⇒ Boolean
Check if an icon exists before rendering
37 38 39 40 41 |
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 37 def nav_icon_exists?(icon_name) return false if icon_name.blank? lookup_context.exists?("shared/icons/#{icon_name}", [], true) end |
#nav_link_active?(link) ⇒ Boolean
Check if a navigation link is currently active
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'app/helpers/neon_sakura/navbar_helper.rb', line 8 def nav_link_active?(link) return false unless link[:path] is_active = current_page?(link[:path]) rescue false return true if is_active # Check additional active_paths if present if link[:active_paths] link[:active_paths].any? { |path| current_page?(path) rescue false } else false end end |