|
|
|
@ -11,6 +11,7 @@ class Widget::Base < Widget |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def render_with_options(options = {}, &block) |
|
|
|
|
help_text = options[:help_text] |
|
|
|
|
if canvas = options[:to] |
|
|
|
|
canvas << "\n" << render(&block) |
|
|
|
|
else |
|
|
|
@ -22,15 +23,23 @@ class Widget::Base < Widget |
|
|
|
|
# An optional help text. If defined the Help Widget |
|
|
|
|
# displaying the given text is going to be placed |
|
|
|
|
# next to this Widget, if it supports that. |
|
|
|
|
def help_text; end |
|
|
|
|
def help_text |
|
|
|
|
@help_text |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
def help_text=(text) |
|
|
|
|
@help_text = text |
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
## |
|
|
|
|
# Appends the Help Widget with this Widget's help text |
|
|
|
|
# if it is defined to the input. |
|
|
|
|
# If the help text is not defined the input is returned. |
|
|
|
|
def maybe_with_help(html, options = {}) |
|
|
|
|
if help_text |
|
|
|
|
help = render_widget Widget::Controls::Help, help_text do |
|
|
|
|
text = options[:text] |
|
|
|
|
text ||= help_text unless options[:ignore_default] |
|
|
|
|
if text |
|
|
|
|
help = render_widget Widget::Controls::Help, text do |
|
|
|
|
options |
|
|
|
|
end |
|
|
|
|
html + help |
|
|
|
|