create output canvas on demand

pull/6827/head
Tim Felgentreff 14 years ago
parent bb3f9f0faa
commit d740f5f6e0
  1. 11
      lib/widget/base.rb

@ -4,10 +4,10 @@ class Widget::Base < Widget
def initialize(query) def initialize(query)
@query = query @query = query
@engine = query.class @engine = query.class
@output = "".html_safe
end end
def write(str) def write(str)
@output ||= "".html_safe
@output.write str @output.write str
end end
@ -16,13 +16,8 @@ class Widget::Base < Widget
end end
def render_with_options(options = {}, &block) def render_with_options(options = {}, &block)
if canvas = options[:to] @output = options[:to] if options.has_key? :to
@output = canvas render(&block)
end
result = render(&block)
if @output.respond_to? :to_str and @output.empty? # FIXME: Transitional support
@output += "\n#{result}".html_safe
end
@output @output
end end
end end

Loading…
Cancel
Save