-
Notifications
You must be signed in to change notification settings - Fork 0
Misc
Ryuji EGUCHI edited this page Nov 21, 2019
·
11 revisions
-
rubylar - a Ruby regular expression editor
-
Reference Implementation
-
Recommended Books
-
- Status Cake, Uptime Robot など
-
SimpleDelegatorでDecoratorを作る 参考: https://webuilder240.hatenablog.com/entry/2018/11/09/231436
# app/presenters/dashboard/sidebar_link_presenter.rb
module Dashboard
class SidebarLinkPresenter < SimpleDelegator
attr_reader :title, :url, :i_class, :options
def initialize(view, title:, url:, i_class: nil)
super(view)
@title = title
@url = url
@i_class = i_class
@options = options
end
def call
content_tag(:li) do
active_link_to(url, class: "b-dashboardSidebar__link", active: :exact, class_active: "is-current") do
concat(content_tag(:i, nil, class: i_class))
concat(title)
end
end
end
end
end
# app/views/layouts/_dashboard_sidebar.html.erb
<aside class="b-dashboardSidebar">
<nav>
<ul>
<%= Dashboard::SidebarLinkPresenter.new(self, title: t('other.header.work'), url: "/dashboard/works", i_class: "i-dashboardWorks").call %>
</ul>
</nav>
</aside>