Module: ActionviewPrecompiler::PrismASTParser

Defined in:
lib/actionview_precompiler/ast_parser/prism.rb

Defined Under Namespace

Classes: CompilationError, RenderCall, RenderNode, RenderVisitor

Class Method Summary collapse

Class Method Details

.parse_render_nodes(code) ⇒ Object

Main entrypoint into this AST parser variant. It’s responsible for returning a hash of render calls. The keys are the method names, and the values are arrays of call objects.



143
144
145
146
147
148
149
150
151
152
153
# File 'lib/actionview_precompiler/ast_parser/prism.rb', line 143

def self.parse_render_nodes(code)
  visitor = RenderVisitor.new
  result = Prism.parse(code)

  if result.success?
    result.value.accept(visitor)
    visitor.render_calls
  else
    raise CompilationError, "Unable to parse the template"
  end
end