mirror of
https://github.com/discourse/discourse.git
synced 2025-02-18 21:02:48 +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")
|
@all_connectors = Dir.glob("plugins/*/app/views/connectors/**/*.html.erb")
|
||||||
end
|
end
|
||||||
|
|
||||||
def server_plugin_outlet(name)
|
def server_plugin_outlet(name, locals: nil)
|
||||||
|
|
||||||
# Don't evaluate plugins in test
|
|
||||||
return "" if Rails.env.test?
|
|
||||||
|
|
||||||
matcher = Regexp.new("/connectors/#{name}/.*\.html\.erb$")
|
matcher = Regexp.new("/connectors/#{name}/.*\.html\.erb$")
|
||||||
erbs = ApplicationHelper.all_connectors.select { |c| c =~ matcher }
|
erbs = ApplicationHelper.all_connectors.select { |c| c =~ matcher }
|
||||||
return "" if erbs.blank?
|
return "" if erbs.blank?
|
||||||
|
|
||||||
result = +""
|
result = +""
|
||||||
erbs.each { |erb| result << render(inline: File.read(erb)) }
|
erbs.each { |erb| result << render(inline: File.read(erb), locals: locals) }
|
||||||
result.html_safe
|
result.html_safe
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -113,6 +113,8 @@
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
|
<%= server_plugin_outlet("after_post_body", locals: {post: post}) %>
|
||||||
</div>
|
</div>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user