Class: Kadmin::Navbar::Link::Presenter
- Defined in:
- app/components/kadmin/navbar/link.rb
Overview
Generates HTML for use in the main Kadmin layout to build the navigation sidebar
Instance Method Summary collapse
-
#generate(captured) ⇒ ActiveSupport::SafeBuffer
Generates HTML to present the section.
Methods inherited from Presenter
#initialize, #present, #render
Constructor Details
This class inherits a constructor from Kadmin::Presenter
Instance Method Details
#generate(captured) ⇒ ActiveSupport::SafeBuffer
Generates HTML to present the section
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'app/components/kadmin/navbar/link.rb', line 37 def generate(captured, **) path = self.path if self.path.respond_to?(:call) router = self.engine.routes.url_helpers path = self.path.call(router) end css_classes = self.css_classes css_classes = self.css_classes.dup << 'active' if @view.controller.request.path == path contents = @view.link_to(self.text.to_s.html_safe, path) contents << captured if captured.present? return %(<li class="#{css_classes.join(' ')}">#{contents}</li>).html_safe end |