mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 04:31:10 +08:00
Basic support for server side plugin outlets
This commit is contained in:
@ -187,4 +187,22 @@ module ApplicationHelper
|
||||
CategoryBadge.html_for(category, opts).html_safe
|
||||
end
|
||||
|
||||
def self.all_connectors
|
||||
@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?
|
||||
|
||||
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(file: erb) }
|
||||
result.html_safe
|
||||
end
|
||||
|
||||
end
|
||||
|
Reference in New Issue
Block a user