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

Loading…
Cancel
Save