The basic implementation of this in the custom wizard will be
Discourse.unofficial_plugins.each do |plugin|
plugin_name = plugin.metadata.name
if require_plugin_assets = CustomWizard::Field.require_assets[plugin_name]
plugin.each_globbed_asset do |f, is_dir|
if f.include? "raw.hbs"
name = File.basename(f, ".raw.hbs")
compiled = Barber::Precompiler.new().compile(File.read(f))
result << "
(function() {
if ('Wizard' in window) {
Wizard.RAW_TEMPLATES['#{name}'] = requirejs('discourse-common/lib/raw-handlebars').template(#{compiled});
}
})();
"
end
end
end
end
Which just requires a plugin to include ‘templates’ in the assets they add to the wizard asset pipeline, e.g.
CustomWizard::Field.add_assets('location', 'discourse-locations', ['components', 'helpers', 'lib', 'stylesheets', 'templates'])
The upshot being, I can access the pre-compiled a raw template in a common component by just switching the global namespace:
const global = this.get('global');
let template = global.RAW_TEMPLATES['javascripts/location-autocomplete'];