app/controllers/concerns/enjoy/pages/blocksetable.rb in enjoy_cms_pages-0.4.0.beta3 vs app/controllers/concerns/enjoy/pages/blocksetable.rb in enjoy_cms_pages-0.4.0

- old
+ new

@@ -30,27 +30,50 @@ end def render_blockset(view, type) ret = [] begin - blocks = blockset_get_blocks(type) + blockset = get_blockset(type) + blocks = blockset_get_blocks_for_render(blockset) blocks.each do |block| - ret << block.render_or_content_html(view) + ret << block.render_or_content_html(view) do |html| + after_render_blockset_block block, html + end end + ret = blockset.render(view, ret.join.html_safe) do |html| + after_render_blockset blockset, html + end rescue Exception => exception Rails.logger.error exception.message Rails.logger.error exception.backtrace.join("\n") puts exception.message puts exception.backtrace.join("\n") capture_exception(exception) if respond_to?(:capture_exception) # ret << blocks || [] end - ret.join.html_safe + ret.is_a?(Array) ? ret.join.html_safe : ret end + def after_render_blockset_block(block, html) + html + end + + def after_render_blockset(blockset, html) + html + end + + def get_blockset(type) + type.is_a?(Enjoy::Pages::Blockset) ? type : blockset_class.find(type.to_s) + end + def blockset_get_blocks(type) - blockset = blockset_class.find(type.to_s) + blockset = get_blockset type blockset.blocks.enabled.show_in_menu.sorted.to_a if blockset + end + + def blockset_get_blocks_for_render(type) + blockset = get_blockset type + blockset.blocks.enabled.sorted.to_a if blockset end def blockset_class_name "Enjoy::Pages::Blockset" end