Module: RenderSuperVisagio::InstanceMethods
- Defined in:
- lib/render_super_visagio.rb
Instance Method Summary collapse
-
#render_with_super(*args, &block) ⇒ Object
Adds rendering option.
- #view_stack ⇒ Object
Instance Method Details
#render_with_super(*args, &block) ⇒ Object
Adds rendering option.
render :super
This renders the “super” template, i.e. the one hidden by the plugin
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/render_super_visagio.rb', line 43 def render_with_super(*args, &block) if args.first == :super last_view = view_stack.last || {:view => instance_variable_get(:@virtual_path).split('/').last} = args[1] || {} [:locals] ||= {} [:locals].reverse_merge!(last_view[:locals] || {}) if last_view[:templates].nil? last_view[:templates] = lookup_context.find_all_templates(last_view[:view], last_view[:partial], [:locals].keys) last_view[:templates].shift end [:template] = last_view[:templates].shift view_stack << last_view result = render_without_super view_stack.pop result else = args.first if .is_a?(Hash) current_view = {:view => [:partial], :partial => true} if [:partial] current_view = {:view => [:template], :partial => false} if current_view.nil? && [:template] current_view[:locals] = [:locals] if !current_view.nil? && [:locals] view_stack << current_view if current_view.present? end result = render_without_super(*args, &block) view_stack.pop if current_view.present? result end end |
#view_stack ⇒ Object
73 74 75 |
# File 'lib/render_super_visagio.rb', line 73 def view_stack @_view_stack ||= [] end |