mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 03:01:22 +08:00
FEATURE: detect theme errors and catch them (#7589)
* FEATURE: detect theme errors and catch them * Bump COMPILER_VERSION * Feedback * Override eslint no console for one line * Can't use our ajax method * remove emoji from translation file
This commit is contained in:
@ -147,9 +147,10 @@ class ThemeJavascriptCompiler
|
||||
|
||||
attr_accessor :content
|
||||
|
||||
def initialize(theme_id)
|
||||
def initialize(theme_id, theme_name)
|
||||
@theme_id = theme_id
|
||||
@content = +""
|
||||
@theme_name = theme_name
|
||||
end
|
||||
|
||||
def prepend_settings(settings_hash)
|
||||
@ -212,12 +213,18 @@ class ThemeJavascriptCompiler
|
||||
wrapped = <<~PLUGIN_API_JS
|
||||
(function() {
|
||||
if ('Discourse' in window && typeof Discourse._registerPluginCode === 'function') {
|
||||
const __theme_name__ = "#{@theme_name.gsub('"', "\\\"")}";
|
||||
const settings = Discourse.__container__
|
||||
.lookup("service:theme-settings")
|
||||
.getObjectForTheme(#{@theme_id});
|
||||
const themePrefix = (key) => `theme_translations.#{@theme_id}.${key}`;
|
||||
Discourse._registerPluginCode('#{version}', api => {
|
||||
try {
|
||||
#{es6_source}
|
||||
} catch(err) {
|
||||
const rescue = require("discourse/lib/utilities").rescueThemeError;
|
||||
rescue(__theme_name__, err, api);
|
||||
}
|
||||
});
|
||||
}
|
||||
})();
|
||||
|
Reference in New Issue
Block a user