mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Allow themes to specify modifiers in their about.json file (#9097)
There are three modifiers: - serialize_topic_excerpts (boolean) - csp_extensions (array of strings) - svg_icons (array of strings) When multiple themes are active, the values will be combined. The combination method varies based on the setting. CSP/SVG arrays will be combined. serialize_topic_excerpts will use `Enumerable#any`.
This commit is contained in:
12
lib/theme_modifier_helper.rb
Normal file
12
lib/theme_modifier_helper.rb
Normal file
@@ -0,0 +1,12 @@
|
||||
# frozen_string_literal: true
|
||||
class ThemeModifierHelper
|
||||
def initialize(request: nil, theme_ids: nil)
|
||||
@theme_ids = theme_ids || request&.env&.[](:resolved_theme_ids)
|
||||
end
|
||||
|
||||
ThemeModifierSet::MODIFIERS.keys.each do |modifier|
|
||||
define_method(modifier) do
|
||||
Theme.lookup_modifier(@theme_ids, modifier)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user