Basic support for server side plugin outlets

This commit is contained in:
Robin Ward 2015-06-02 14:27:52 -04:00
parent 4dfb1de77e
commit 92cddfa598
2 changed files with 19 additions and 0 deletions

View File

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

View File

@ -12,6 +12,7 @@
<meta itemprop='position' content='<%= i + 1 %>'>
<% end %>
</div>
<%= server_plugin_outlet "topic_header" %>
<hr>
<% @topic_view.posts.each do |post| %>