Sha256: 71d3f7299cff110b19a41f4636fa5617bec186726a1ca1435c441bc92271882d

Contents?: true

Size: 1.31 KB

Versions: 1

Compression:

Stored size: 1.31 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: -> {
                             div._sidebar_wrapper {
                               aside.sidebar {
                                 h1 {
                                   menu_name
                                 }
                                 ul {
                                   _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

1 entries across 1 versions & 1 rubygems

Version Path
express_admin-1.1.0 app/components/express_admin/addon_sidebar_component.rb