mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 16:53:44 +08:00
FEATURE: allow locals to be passed in server_plugin_outlet (#16850)
This commit is contained in:
parent
0af05c2682
commit
defa5a4e94
|
@ -449,17 +449,13 @@ module ApplicationHelper
|
|||
@all_connectors = Dir.glob("plugins/*/app/views/connectors/**/*.html.erb")
|
||||
end
|
||||
|
||||
def server_plugin_outlet(name)
|
||||
|
||||
# Don't evaluate plugins in test
|
||||
return "" if Rails.env.test?
|
||||
|
||||
def server_plugin_outlet(name, locals: nil)
|
||||
matcher = Regexp.new("/connectors/#{name}/.*\.html\.erb$")
|
||||
erbs = ApplicationHelper.all_connectors.select { |c| c =~ matcher }
|
||||
return "" if erbs.blank?
|
||||
|
||||
result = +""
|
||||
erbs.each { |erb| result << render(inline: File.read(erb)) }
|
||||
erbs.each { |erb| result << render(inline: File.read(erb), locals: locals) }
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
|
|
|
@ -113,6 +113,8 @@
|
|||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<%= server_plugin_outlet("after_post_body", locals: {post: post}) %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
|
|
Loading…
Reference in New Issue
Block a user