lib/apotomo/rails/view_helper.rb in apotomo-1.2.4 vs lib/apotomo/rails/view_helper.rb in apotomo-1.2.5

- old
+ new

@@ -14,42 +14,50 @@ # # - children.each do |kid| # = render_widget kid module ViewHelper delegate :children, :url_for_event, :widget_id, :to => :controller - + # Returns the app JavaScript generator. def js_generator Apotomo.js_generator end - + # Creates a form that submits itself via an iFrame and executes the response # in the parent window. This is needed to upload files via AJAX. # # Better call <tt>#form_to_event :multipart => true</tt> and stay forward-compatible. def multipart_form_to_event(type, options={}, html_options={}, &block) options.reverse_merge! :apotomo_iframe => true html_options.reverse_merge! :target => :apotomo_iframe, :multipart => true - + # i hate rails: concat('<iframe id="apotomo_iframe" name="apotomo_iframe" style="display: none;"></iframe>'.html_safe) << form_tag(url_for_event(type, options), html_options, &block) end - - # Wraps your content in a +div+ and sets the id. Feel free to pass additional html options. + + # Wraps your widget content in a +div+. See #widget_tag. + def widget_div(*args, &block) + widget_tag(:div, *args, &block) + end + + # Wraps your widget content in a +tag+ tag and sets the id. Feel free to pass additional html options. # - # Example: - # - # - widget_div do + # - widget_tag :span do # %p I'm wrapped # # will render # - # <div id="mouse"> + # <span id="mouse"> # <p>I'm wrapped</p> - # </div> - def widget_div(options={}, &block) - options.reverse_merge!(:id => widget_id) - content_tag(:div, options, &block) + # </span> + # + # Note that you can set the +id+ and other options manually. + # + # - widget_tag :div, id: "comments", class: "yellow" + def widget_tag(tag, options={}, &block) + options.reverse_merge!(:id => widget_id) + + content_tag(tag, options, &block) end - end + end end end