Skip to content

A platform for community discussion. Free, open, simple.

FEATURE: allow locals to be passed in server_plugin_outlet (#16850)

Arpit Jalandefa5a4e94c1
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 64b6d30f116..ace6f424a95 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -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
diff --git a/app/views/topics/show.html.erb b/app/views/topics/show.html.erb
index d949ebb2b0e..e2d8ae9cb3e 100644
--- a/app/views/topics/show.html.erb
+++ b/app/views/topics/show.html.erb
@@ -113,6 +113,8 @@
<% end %>
</div>
<% end %>
+
+ <%= server_plugin_outlet("after_post_body", locals: {post: post}) %>
</div>
<% end %>
<% end %>