DEV: Drop legacy topic-list and raw-handlebars compilation system (#32081)

This commit is contained in:
David Taylor
2025-04-14 10:42:40 +01:00
committed by GitHub
parent 13cb472ec8
commit f0057c7353
127 changed files with 156 additions and 3420 deletions

View File

@ -100,14 +100,6 @@ class ThemeJavascriptCompiler
tree.transform_keys! do |filename|
if filename.ends_with? ".js.es6"
filename.sub(/\.js\.es6\z/, ".js")
elsif filename.include? "/templates/"
filename = filename.sub(/\.raw\.hbs\z/, ".hbr") if filename.ends_with? ".raw.hbs"
if filename.ends_with? ".hbr"
filename.sub(%r{/templates/}, "/raw-templates/")
else
filename
end
else
filename
end
@ -176,8 +168,6 @@ class ThemeJavascriptCompiler
append_module(content, module_name, extension, include_variables:)
elsif extension == "hbs"
append_ember_template(module_name, content)
elsif extension == "hbr"
append_raw_template(module_name.sub("discourse/raw-templates/", ""), content)
else
append_js_error(filename, "unknown file extension '#{extension}' (#{filename})")
end
@ -208,40 +198,6 @@ class ThemeJavascriptCompiler
raise CompileError.new ex.message
end
def raw_template_name(name)
name.sub(/\.(raw|hbr)\z/, "")
end
def append_raw_template(name, hbs_template)
compiled =
DiscourseJsProcessor::Transpiler.new.compile_raw_template(hbs_template, theme_id: @theme_id)
source_for_comment = hbs_template.gsub("*/", '*\/').indent(4, " ")
modern_replacement_marker = hbs_template.include?("{{!-- has-modern-replacement --}}")
source = <<~JS
/*
#{source_for_comment}
*/
import { template as compiler } from "discourse/lib/raw-handlebars";
import { addRawTemplate } from "discourse/lib/raw-templates";
let template = compiler(#{compiled});
addRawTemplate(#{raw_template_name(name).to_json}, template, {
themeId: #{@theme_id},
themeName: #{@theme_name.to_json},
hasModernReplacement: #{modern_replacement_marker}
});
export default template;
JS
append_module source, "raw-templates/#{raw_template_name(name)}", "js", include_variables: false
rescue MiniRacer::RuntimeError, DiscourseJsProcessor::TranspileError => ex
raise CompileError.new ex.message
end
def append_raw_script(filename, script)
@output_tree << [filename, script + "\n"]
end