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

This commit is contained in:
Arpit Jalan 2022-05-20 10:00:24 +05:30 committed by GitHub
parent 0af05c2682
commit defa5a4e94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 6 deletions

View File

@ -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

View File

@ -113,6 +113,8 @@
<% end %>
</div>
<% end %>
<%= server_plugin_outlet("after_post_body", locals: {post: post}) %>
</div>
<% end %>
<% end %>