Class: ActionView::Base
- Inherits:
-
Object
- Object
- ActionView::Base
- Defined in:
- lib/malline/adapters/rails-2.0.rb
Overview
We need to redefine some ActionView::Base methods, Since Rails 2.0 doesn’t offer any better way to do some things.
Instance Method Summary collapse
- #compile_and_render_template(handler, *rest) ⇒ Object
-
#delegate_render(handler, template, local_assigns) ⇒ Object
Update the current file to malline and tell Malline to be deactivated if there is a non-Malline partial inside Malline template.
- #orig_compile_and_render_template ⇒ Object
- #orig_delegate_render ⇒ Object
- #orig_render_template ⇒ Object
-
#render_template(template_extension, template, file_path = nil, *rest) ⇒ Object
We want to save the name of the current file to @current_tpl_path, because then the error backtrace from Rails will include the name of the file.
Instance Method Details
#compile_and_render_template(handler, *rest) ⇒ Object
33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/malline/adapters/rails-2.0.rb', line 33 def compile_and_render_template handler, *rest if self.respond_to? :is_malline? old, @malline_is_active = is_malline?, false output = orig_compile_and_render_template handler, *rest @malline_is_active = old output else @malline_is_active = false orig_compile_and_render_template handler, *rest end end |
#delegate_render(handler, template, local_assigns) ⇒ Object
Update the current file to malline and tell Malline to be deactivated if there is a non-Malline partial inside Malline template.
48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/malline/adapters/rails-2.0.rb', line 48 def delegate_render(handler, template, local_assigns) old = is_malline? tmp = if handler == Malline::Base h = handler.new(self) h.path = @current_tpl_path if @current_tpl_path @malline_is_active = true h.render(template, local_assigns) else @malline_is_active = false orig_delegate_render(handler, template, local_assigns) end @malline_is_active = old tmp end |
#orig_compile_and_render_template ⇒ Object
32 |
# File 'lib/malline/adapters/rails-2.0.rb', line 32 alias_method :orig_compile_and_render_template, :compile_and_render_template |
#orig_delegate_render ⇒ Object
45 |
# File 'lib/malline/adapters/rails-2.0.rb', line 45 alias_method :orig_delegate_render, :delegate_render |
#orig_render_template ⇒ Object
23 |
# File 'lib/malline/adapters/rails-2.0.rb', line 23 alias_method :orig_render_template, :render_template |
#render_template(template_extension, template, file_path = nil, *rest) ⇒ Object
We want to save the name of the current file to @current_tpl_path, because then the error backtrace from Rails will include the name of the file. I didn’t find better way to get this
27 28 29 30 |
# File 'lib/malline/adapters/rails-2.0.rb', line 27 def render_template template_extension, template, file_path = nil, *rest @current_tpl_path = file_path orig_render_template(template_extension, template, file_path, *rest) end |