Module: Grapple::Helpers::TableHelper
- Defined in:
- lib/grapple/helpers/table_helper.rb
Constant Summary collapse
- @@builder =
Grapple::DataGridBuilder
Instance Method Summary collapse
- #grapple_container(*args, &block) ⇒ Object
- #grapple_request_params ⇒ Object
- #table_for(columns, records, *args, &block) ⇒ Object
Instance Method Details
#grapple_container(*args, &block) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/grapple/helpers/table_helper.rb', line 33 def grapple_container(*args, &block) = args[0] || {} builder_class = [:builder] || @@builder container_attr = builder_class.container_attributes(self, ) html = '' html << builder_class.before_container(self, ) html << tag('div', container_attr, true) + "\n" html << capture(&block) html << "</div>\n" html << builder_class.after_container(self, ) return html.html_safe end |
#grapple_request_params ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/grapple/helpers/table_helper.rb', line 25 def grapple_request_params # params might not be defined (being called from a mailer) # HACK: "defined? params" is returning method but when it gets called the method is not defined params() rescue request.params() rescue {} end |
#table_for(columns, records, *args, &block) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/grapple/helpers/table_helper.rb', line 8 def table_for(columns, records, *args, &block) = args[0] || {} # Don't render the container for AJAX requests by default render_container = ([:container].nil? ? !request.xhr? : [:container]) rescue false table_html_attributes = [:html] || {} [:builder] = [:builder] || @@builder request_params = [:params] ? [:params] : grapple_request_params builder = [:builder].new(self, columns, records, request_params, ) output = capture(builder, &block) table_html = (builder.before_table + builder.table(output, table_html_attributes) + builder.after_table) if render_container builder.container(table_html) else table_html.html_safe end end |