mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: we need access to settings in theme js
This commit is contained in:
@@ -24,10 +24,28 @@ class ThemeField < ActiveRecord::Base
|
||||
|
||||
belongs_to :theme
|
||||
|
||||
def settings(source)
|
||||
|
||||
settings = {}
|
||||
|
||||
theme.cached_settings.each do |k, v|
|
||||
if source.include?("settings.#{k}")
|
||||
settings[k] = v
|
||||
end
|
||||
end
|
||||
|
||||
if settings.length > 0
|
||||
"let settings = #{settings.to_json};"
|
||||
else
|
||||
""
|
||||
end
|
||||
end
|
||||
|
||||
def transpile(es6_source, version)
|
||||
template = Tilt::ES6ModuleTranspilerTemplate.new {}
|
||||
wrapped = <<PLUGIN_API_JS
|
||||
Discourse._registerPluginCode('#{version}', api => {
|
||||
#{settings(es6_source)}
|
||||
#{es6_source}
|
||||
});
|
||||
PLUGIN_API_JS
|
||||
|
||||
@@ -7,6 +7,8 @@ class ThemeSetting < ActiveRecord::Base
|
||||
|
||||
after_save do
|
||||
theme.clear_cached_settings!
|
||||
theme.remove_from_cache!
|
||||
theme.theme_fields.update_all(value_baked: nil)
|
||||
end
|
||||
|
||||
def self.types
|
||||
|
||||
Reference in New Issue
Block a user