Simplify common HTML attributes using tag.attributes
The `tag.attributes` method was introduced in Rails 7.0.
This commit is contained in:
@@ -4,18 +4,18 @@ class Layout::CommonHtmlAttributesComponent < ApplicationComponent
|
|||||||
private
|
private
|
||||||
|
|
||||||
def attributes
|
def attributes
|
||||||
sanitize([dir, lang, html_class].compact.join(" "))
|
tag.attributes(dir: dir, lang: lang, class: html_class)
|
||||||
end
|
end
|
||||||
|
|
||||||
def dir
|
def dir
|
||||||
'dir="rtl"' if rtl?
|
"rtl" if rtl?
|
||||||
end
|
end
|
||||||
|
|
||||||
def lang
|
def lang
|
||||||
"lang=\"#{I18n.locale}\""
|
I18n.locale
|
||||||
end
|
end
|
||||||
|
|
||||||
def html_class
|
def html_class
|
||||||
"class=\"tenant-#{Tenant.current_schema}\"" if Rails.application.config.multitenancy
|
"tenant-#{Tenant.current_schema}" if Rails.application.config.multitenancy
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user