app/models/activeadmin_selleo_cms/section.rb in activeadmin-selleo-cms-0.0.44 vs app/models/activeadmin_selleo_cms/section.rb in activeadmin-selleo-cms-0.0.45

- old
+ new

@@ -50,14 +50,33 @@ def related_items current_translation.related_items end + def render(editing=false) + doc = Nokogiri::HTML(body.to_s) + + unless editing + av = ActionView::Base.new + av.instance_eval do + def protect_against_forgery? + false + end + end + + doc.css('form[data-form-id]').each do |form| + form.replace av.render(:file => File.join(ActiveadminSelleoCms::Engine.root, 'app/views/forms/_form'), :layout => nil, :locals => { :form => Form.find(form.attributes["data-form-id"].to_s) }) + end + end + + doc.to_s.html_safe + end + def to_s section_definition = sectionable.layout.find_section(name) if sectionable and sectionable.respond_to? :layout if section_definition if section_definition.text? - body.to_s.html_safe + render_body elsif section_definition.image? image ? image.url : "" end end end