Module: DeadSimpleCMS::Group::Presenter::RenderMixin
- Included in:
- DeadSimpleCMS::Group, Configuration
- Defined in:
- lib/dead_simple_cms/group/presenter/render_mixin.rb
Overview
Public: Module to add rendering of lambda and presenters for DeadSimpleCMS::Group.
Instance Method Summary collapse
-
#display(presenter_class_or_block = nil, &block) ⇒ Object
Public: Set different mechanisms for rendering this group.
- #presenter_class ⇒ Object
-
#render(view_context, *args) ⇒ Object
Public: Render the group using the passed in proc in the scope of the template.
- #render_proc ⇒ Object
Instance Method Details
#display(presenter_class_or_block = nil, &block) ⇒ Object
Public: Set different mechanisms for rendering this group.
17 18 19 20 21 |
# File 'lib/dead_simple_cms/group/presenter/render_mixin.rb', line 17 def display(presenter_class_or_block=nil, &block) @display = presenter_class_or_block if presenter_class_or_block @display = block if block_given? @display end |
#presenter_class ⇒ Object
8 9 10 |
# File 'lib/dead_simple_cms/group/presenter/render_mixin.rb', line 8 def presenter_class display if display.is_a?(Class) && display < Presenter::Base end |
#render(view_context, *args) ⇒ Object
Public: Render the group using the passed in proc in the scope of the template.
If you include this module in something other then a DeadSimpleCMS::Group, you can pass in the group directly with the first argument:
render([view_context, group], *args) # and also
render(view_context, *args)
31 32 33 34 35 36 37 |
# File 'lib/dead_simple_cms/group/presenter/render_mixin.rb', line 31 def render(view_context, *args) view_context, group = view_context.is_a?(Array) ? view_context : [view_context, self] case display when Proc then view_context.instance_exec(group, *args, &display) when Class then display.new(view_context, group, *args).render if display < Presenter::Base end end |
#render_proc ⇒ Object
12 13 14 |
# File 'lib/dead_simple_cms/group/presenter/render_mixin.rb', line 12 def render_proc display if display.is_a?(Proc) end |