Module: RenderSuper::InstanceMethods
- Defined in:
- lib/render_super_visagio.rb
Instance Method Summary collapse
-
#render(*args, &block) ⇒ Object
Adds rendering option.
- #view_stack ⇒ Object
Instance Method Details
#render(*args, &block) ⇒ Object
Adds rendering option.
render :super
This renders the “super” template, i.e. the one hidden by the plugin
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/render_super_visagio.rb', line 34 def render(*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 = 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 = super view_stack.pop if current_view.present? result end end |
#view_stack ⇒ Object
64 65 66 |
# File 'lib/render_super_visagio.rb', line 64 def view_stack @_view_stack ||= [] end |