Module: ActionviewPrecompiler::SyntaxTreeASTParser

Defined in:
lib/actionview_precompiler/ast_parser/syntax_tree.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.



150
151
152
153
154
155
156
# File 'lib/actionview_precompiler/ast_parser/syntax_tree.rb', line 150

def self.parse_render_nodes(code)
  visitor = RenderVisitor.new
  SyntaxTree.parse(code).accept(visitor)
  visitor.render_calls
rescue SyntaxTree::Parser::ParseError
  raise CompilationError, "Unable to parse the template"
end