Class: ActionView::Template
- Inherits:
-
Object
- Object
- ActionView::Template
- Defined in:
- lib/template_render_overrider.rb
Overview
TODO: test for ajax case
create specs
Instance Method Summary collapse
Instance Method Details
#render_with_map_wrap(*args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/template_render_overrider.rb', line 6 def render_with_map_wrap(*args, &block) part_html = render_without_map_wrap(*args, &block) res = if mime_type.nil? || mime_type === [Mime::HTML, Mime::XML] template_file = Pathname.new(self.inspect) # show internal paths relative from Rails.root if template_file.to_s =~ /#{Rails.root.parent}.*/ # "parent" used for showing as relative extensions placed on same level with main app template_file = template_file.relative_path_from Rails.root else if template_file.to_s =~ /\/app\/views\/(.*)/ resource_path, resource_name = Pathname.new($1).split end end wrapped = [] wrapped << "<!-- TEMPLATE: #{template_file} -->" # TODO: make this by ajax call if resource_name wrapped << "<!-- \n For overriding this partial you may run from project (or engine/extension) dir:\n $ mkdir -p app/views/\#{resource_path} && cp -i \#{template_file} app/views/\#{resource_path}/\#{resource_name}\n NOTE: Please make sure that it is what you want before running. In common case it is.\n-->\n" end wrapped << part_html wrapped << "<!-- END TEMPLATE: #{template_file} -->" wrapped.join("\n"); else part_html end res.html_safe end |