In rubocop-rails 2.26.0, the Rails/CompactBlank rule was modified to handle cases where select(&:present?) is used. After identifying three occurrences in our code, we've decided to apply this rule as it encourages the use of the more efficient and clearer method, compact_blank. By using compact_blank, we improve code clarity and performance, as this method performs the same operation but in a more optimized way.
30 lines
720 B
Ruby
30 lines
720 B
Ruby
module Header
|
|
extend ActiveSupport::Concern
|
|
|
|
def header(before: nil, skip_section_title: false, &block)
|
|
provide(:title) do
|
|
[
|
|
(t("#{namespace}.header.title", default: "") unless skip_section_title),
|
|
strip_tags(title),
|
|
setting["org_name"]
|
|
].compact_blank.join(" - ")
|
|
end
|
|
|
|
heading_tag = if %w[admin management moderation sdg_management valuation].include?(namespace)
|
|
"h2"
|
|
else
|
|
"h1"
|
|
end
|
|
|
|
tag.header do
|
|
safe_join([before, content_tag(heading_tag, title), (capture(&block) if block)].compact)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def namespace
|
|
controller_path.split("/").first
|
|
end
|
|
end
|