mirror of
https://github.com/discourse/discourse.git
synced 2025-05-24 03:36:18 +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
|
CategoryBadge.html_for(category, opts).html_safe
|
||||||
end
|
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
|
end
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<meta itemprop='position' content='<%= i + 1 %>'>
|
<meta itemprop='position' content='<%= i + 1 %>'>
|
||||||
<% end %>
|
<% end %>
|
||||||
</div>
|
</div>
|
||||||
|
<%= server_plugin_outlet "topic_header" %>
|
||||||
<hr>
|
<hr>
|
||||||
|
|
||||||
<% @topic_view.posts.each do |post| %>
|
<% @topic_view.posts.each do |post| %>
|
||||||
|
Reference in New Issue
Block a user