Class: SimpleModelView::ActionViewHelperBuilder
- Inherits:
-
Object
- Object
- SimpleModelView::ActionViewHelperBuilder
- Includes:
- TemplateHelpers
- Defined in:
- lib/simple_model_view/action_view_helper_builder.rb
Instance Attribute Summary collapse
-
#template ⇒ Object
readonly
Returns the value of attribute template.
Instance Method Summary collapse
- #collection_table(collection, *args) ⇒ Object
-
#initialize(template) ⇒ ActionViewHelperBuilder
constructor
A new instance of ActionViewHelperBuilder.
- #resource_table(model, *args) ⇒ Object
Methods included from TemplateHelpers
#blank_span, #block_concat, #merge_html_attrs
Constructor Details
#initialize(template) ⇒ ActionViewHelperBuilder
Returns a new instance of ActionViewHelperBuilder.
7 8 9 |
# File 'lib/simple_model_view/action_view_helper_builder.rb', line 7 def initialize(template) @template = template end |
Instance Attribute Details
#template ⇒ Object (readonly)
Returns the value of attribute template.
11 12 13 |
# File 'lib/simple_model_view/action_view_helper_builder.rb', line 11 def template @template end |
Instance Method Details
#collection_table(collection, *args) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/simple_model_view/action_view_helper_builder.rb', line 23 def collection_table(collection, *args) builder = SimpleModelView::CollectionTableBuilder.new template, collection, *args template.content_tag :table, nil, SimpleModelView.collection_table_html do block_concat do template.content_tag :thead do template.content_tag :tr do columns_builder = builder.columns_builder yield columns_builder end end end block_concat do template.content_tag :tbody do collection.each do |el| block_concat do template.content_tag :tr do row_builder = builder.row_builder_for el yield row_builder end end end end end end end |
#resource_table(model, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/simple_model_view/action_view_helper_builder.rb', line 13 def resource_table(model, *args) builder = SimpleModelView::ResourceTableBuilder.new template, model, *args template.content_tag :table, nil, SimpleModelView.collection_table_html do template.content_tag :tbody do yield builder end end end |