0
0
Fork 1
Spiegel von https://github.com/paviliondev/discourse-custom-wizard.git synchronisiert 2024-11-24 18:30:27 +01:00
discourse-custom-wizard/assets/javascripts/wizard-raw-templates.js.erb

37 Zeilen
929 B
Text

<%=
result = ''
Discourse.unofficial_plugins.each do |plugin|
plugin_name = plugin.metadata.name
2019-11-20 13:08:04 +01:00
if plugin_name == 'discourse-custom-wizard' || CustomWizard::Field.require_assets[plugin_name]
files = []
plugin.each_globbed_asset do |f, is_dir|
files.push(f) if f.include? "hbr"
2019-11-20 13:08:04 +01:00
end
Dir.glob("#{Rails.root}/app/assets/javascripts/discourse/app/templates/*.hbr").each do |f|
2019-11-20 13:08:04 +01:00
files.push(f)
end
files.each do |f|
name = File.basename(f, ".hbr")
2019-11-20 13:08:04 +01:00
compiled = Barber::Precompiler.new().compile(File.read(f))
result << "
(function() {
2020-10-02 11:32:18 +02:00
requirejs('discourse-common/lib/raw-templates').addRawTemplate(#{compiled});
2019-11-20 13:08:04 +01:00
})();
"
end
result << "
(function() {
2020-10-02 11:32:18 +02:00
window.__DISCOURSE_RAW_TEMPLATES = requirejs('discourse-common/lib/raw-templates').__DISCOURSE_RAW_TEMPLATES;
})();
"
end
end
result
%>