Commit 1ffd3768289057b77e10023c80e89be0294c10e7

Authored by Rafael Reggiani Manzo
1 parent 723a6061

Remove HTML generation from container_block plugin

It now uses BoxesHelper logic instead of HTML generation within the
model violating MVC.

As it is a class within a module
(`ContainerBlockPlugin::ContainerBlock`) `BoxesHelper` required fixes to
handle the module prefix when searching for the proper view to render.
Previously it would wrongly search for
`blocks/container_block_plugin/container.html.erb` instead of
`blocks/container.html.erb`.
app/helpers/boxes_helper.rb
... ... @@ -88,7 +88,7 @@ module BoxesHelper
88 88 end
89 89  
90 90 def render_block block, prefix = nil, klass = block.class
91   - template_name = klass.name.underscore.sub '_block', ''
  91 + template_name = klass.name.demodulize.underscore.sub '_block', ''
92 92 begin
93 93 render template: "blocks/#{prefix}#{template_name}", locals: { block: block }
94 94 rescue ActionView::MissingTemplate
... ...
plugins/container_block/lib/container_block_plugin/container_block.rb
... ... @@ -66,13 +66,6 @@ class ContainerBlockPlugin::ContainerBlock < Block
66 66 children_settings[child_id][:width] if children_settings[child_id]
67 67 end
68 68  
69   - def content(args={})
70   - block = self
71   - proc do
72   - render :file => 'blocks/container', :locals => {:block => block}
73   - end
74   - end
75   -
76 69 def copy_from_with_container(block)
77 70 copy_from_without_container(block)
78 71 children_settings = block.children_settings
... ...