Class: ActionView::RenderParser::PrismRenderParser

Inherits:
Base
  • Object
show all
Defined in:
lib/action_view/render_parser/prism_render_parser.rb

Overview

:nodoc:

Instance Method Summary collapse

Methods inherited from Base

#initialize

Constructor Details

This class inherits a constructor from ActionView::RenderParser::Base

Instance Method Details

#render_callsObject



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
# File 'lib/action_view/render_parser/prism_render_parser.rb', line 6

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)

    options = render_call_options(node)
    next unless options

    render_type = (options.keys & RENDER_TYPE_KEYS)[0]
    template, object_template = render_call_template(options[render_type])
    next unless template

    if options.key?(:object) || options.key?(:collection) || object_template
      next if options.key?(:object) && options.key?(:collection)
      next unless options.key?(:partial)
    end

    if options[:spacer_template].is_a?(Prism::StringNode)
      templates << partial_to_virtual_path(:partial, options[:spacer_template].unescaped)
    end

    templates << partial_to_virtual_path(render_type, template)

    if render_type != :layout && options[:layout].is_a?(Prism::StringNode)
      templates << partial_to_virtual_path(:layout, options[:layout].unescaped)
    end
  end

  templates
end