Sha256: 67f51a34955d8b0226b2fa69a8cdf316d3256418c8ea9fb88c6134f567438a26

Contents?: true

Size: 1.18 KB

Versions: 2

Compression:

Stored size: 1.18 KB

Contents

module ExpressAdmin
  class AddonSidebarComponent < ExpressTemplates::Components::Base
  # Replaces:
  #
  # .sidebar-wrapper
  #   %aside.sidebar
  #     %h5.title= <addon>::Engine.express_admin_menu.name
  #     %ul.side-nav
  #       - <addon>::Engine.express_admin_menu.items.each do |item|
  #         %li
  #           = link_to item.name, eval(item.path)

    helper :menu_name, &-> { current_menu_name }

    emits menu_item:    -> {
                             li {
                               link_to "{{item.title}}", "{{eval(item.path)}}"
                             }
                           },

          menu_wrapper: -> {
                             section._module_sidebar {
                               ul._menu_items {
                                 li.title { menu_name }
                                 _yield
                               }
                             }
                           }

    for_each -> { current_menu.items || [] }, as: :item, emit: :menu_item

    wrap_with :menu_wrapper

    def compile
      %Q(begin
        render(partial: "shared/\#\{current_module_path_name\}/sidebar")
      rescue => e
        #{super}
      end)
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
express_admin-1.2.1 app/components/express_admin/addon_sidebar_component.rb
express_admin-1.2.0 app/components/express_admin/addon_sidebar_component.rb