Pass a context in when using a HTML builder

This commit is contained in:
Robin Ward 2017-04-18 12:35:19 -04:00
parent a19c02f0d3
commit 8b8ee2ad61
4 changed files with 7 additions and 4 deletions

View File

@ -435,7 +435,7 @@ class ApplicationController < ActionController::Base
end
DiscoursePluginRegistry.html_builders.each do |name, blk|
data[name] = blk.call
data[name] = blk.call(self)
end
MultiJson.dump(data)

View File

@ -318,7 +318,7 @@ module ApplicationHelper
def build_plugin_html(name)
return "" unless allow_plugins?
DiscoursePluginRegistry.build_html(name) || ""
DiscoursePluginRegistry.build_html(name, controller) || ""
end
def theme_lookup(name)

View File

@ -53,6 +53,8 @@
<%- end %>
<%= yield :head %>
<%= raw build_plugin_html 'before-head-close' %>
</head>
<body class="<%= body_classes %>">
@ -121,5 +123,6 @@
<%- unless customization_disabled? %>
<%= raw theme_lookup("body_tag") %>
<%- end %>
<%= raw build_plugin_html 'before-body-close' %>
</body>
</html>

View File

@ -134,8 +134,8 @@ class DiscoursePluginRegistry
html_builders[name] = block
end
def self.build_html(name)
html_builders[name]&.call
def self.build_html(name, ctx)
html_builders[name]&.call(ctx)
end
def javascripts