1
0
Fork 0

add wizard raw template pre-compilation

Dieser Commit ist enthalten in:
Angus McLeod 2019-01-29 11:30:35 +11:00
Ursprung 8eee281e25
Commit 2e861f6b69
4 geänderte Dateien mit 26 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -21,4 +21,5 @@
window.Discourse = {} window.Discourse = {}
window.Wizard = {}; window.Wizard = {};
Wizard.SiteSettings = {}; Wizard.SiteSettings = {};
Wizard.RAW_TEMPLATES = {};
Discourse.__widget_helpers = {}; Discourse.__widget_helpers = {};

Datei anzeigen

@ -4,6 +4,8 @@ Discourse.unofficial_plugins.each do |plugin|
plugin_name = plugin.metadata.name plugin_name = plugin.metadata.name
if require_plugin_assets = CustomWizard::Field.require_assets[plugin_name] if require_plugin_assets = CustomWizard::Field.require_assets[plugin_name]
plugin.each_globbed_asset do |f, is_dir| plugin.each_globbed_asset do |f, is_dir|
next if f.include? "raw.hbs"
if require_plugin_assets.any? { |dir| f.include?(dir) } if require_plugin_assets.any? { |dir| f.include?(dir) }
if is_dir if is_dir
depend_on(f) depend_on(f)

Datei anzeigen

@ -0,0 +1,22 @@
<%=
result = ''
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['javascripts/#{name}'] = requirejs('discourse-common/lib/raw-handlebars').template(#{compiled});
}
})();
"
end
end
end
end
result
%>

Datei anzeigen

@ -40,5 +40,6 @@
<%- end %> <%- end %>
<%= preload_script 'wizard-custom-start' %> <%= preload_script 'wizard-custom-start' %>
<%= preload_script 'wizard-raw-templates' %>
</body> </body>
</html> </html>