Class: Kadmin::Navbar::Link::Presenter

Inherits:
Presenter
  • Object
show all
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

Methods inherited from Presenter

#initialize, #render

Constructor Details

This class inherits a constructor from Kadmin::Presenter

Instance Method Details

#generate(**_options) ⇒ ActiveSupport::SafeBuffer

Generates HTML to present the section

Returns:

  • (ActiveSupport::SafeBuffer)

    safe HTML to display



36
37
38
39
40
41
42
# File 'app/components/kadmin/navbar/link.rb', line 36

def generate(**_options)
  css_classes = self.css_classes
  css_classes = self.css_classes.dup << 'active' if @view.controller.request.path == self.path
  contents = @view.link_to(self.text.to_s.html_safe, self.path)

  return %(<li class="#{css_classes.join(' ')}">#{contents}</li>).html_safe
end