Add generic method for header
Unify Header to be able to use it from the admin as from the seg_management.
This commit is contained in:
23
app/components/concerns/header.rb
Normal file
23
app/components/concerns/header.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
module Header
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
def header(&block)
|
||||
provide(:title) do
|
||||
"#{t("#{namespace}.header.title")} - #{title}"
|
||||
end
|
||||
|
||||
tag.header do
|
||||
if block_given?
|
||||
tag.h2(title) + capture(&block)
|
||||
else
|
||||
tag.h2(title)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def namespace
|
||||
controller_path.split("/").first
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user