|
|
|
@ -40,4 +40,26 @@ class Widget < ActionView::Base |
|
|
|
|
def protect_against_forgery? |
|
|
|
|
false |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
module RenderWidgetInstanceMethods |
|
|
|
|
def render_widget(widget, subject, options = {}, &block) |
|
|
|
|
i = widget.new(subject) |
|
|
|
|
if Rails.version.start_with? "3" |
|
|
|
|
i.config = config |
|
|
|
|
i._routes = _routes |
|
|
|
|
else |
|
|
|
|
i.output_buffer = "" |
|
|
|
|
end |
|
|
|
|
i._content_for = @_content_for |
|
|
|
|
i.controller = respond_to? :controller ? controller : self |
|
|
|
|
i.render_with_options(options, &block).html_safe |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
ActionView::Base.send(:include, Widget::RenderWidgetInstanceMethods) |
|
|
|
|
ActionController::Base.send(:include, Widget::RenderWidgetInstanceMethods) |
|
|
|
|
if Rails.version.start_with? "2" |
|
|
|
|
class ::String; def html_safe; self; end; end |
|
|
|
|
end |
|
|
|
|
class ::String; def write(s); concat(s); end; end |
|
|
|
|