Class: ActionView::RenderParser
- Defined in:
- actionview/lib/action_view/render_parser.rb
Overview
:nodoc:
Constant Summary collapse
- ALL_KNOWN_KEYS =
[:partial, :template, :layout, :formats, :locals, :object, :collection, :as, :status, :content_type, :location, :spacer_template]
- RENDER_TYPE_KEYS =
[:partial, :template, :layout]
Instance Method Summary collapse
-
#initialize(name, code) ⇒ RenderParser
constructor
A new instance of RenderParser.
- #render_calls ⇒ Object
Constructor Details
#initialize(name, code) ⇒ RenderParser
Returns a new instance of RenderParser.
10 11 12 13 |
# File 'actionview/lib/action_view/render_parser.rb', line 10 def initialize(name, code) @name = name @code = code end |
Instance Method Details
#render_calls ⇒ Object
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 41 42 43 44 45 46 47 |
# File 'actionview/lib/action_view/render_parser.rb', line 15 def render_calls queue = [Prism.parse(@code).value] templates = [] while (node = queue.shift) queue.concat(node.compact_child_nodes) next unless node.is_a?(Prism::CallNode) = (node) next unless render_type = (.keys & RENDER_TYPE_KEYS)[0] template, object_template = render_call_template([render_type]) next unless template if .key?(:object) || .key?(:collection) || object_template next if .key?(:object) && .key?(:collection) next unless .key?(:partial) end if [:spacer_template].is_a?(Prism::StringNode) templates << partial_to_virtual_path(:partial, [:spacer_template].unescaped) end templates << partial_to_virtual_path(render_type, template) if render_type != :layout && [:layout].is_a?(Prism::StringNode) templates << partial_to_virtual_path(:layout, [:layout].unescaped) end end templates end |