Module: SpanView::Parser

Defined in:
lib/span_view/parser.rb

Overview

Public interface: .span source string in → compiled ERB string out. Pure function, no Rails coupling. Parses with the Span::Grammar, compiles with the Span::Compiler transform.

Class Method Summary collapse

Class Method Details

.call(source) ⇒ Object



13
14
15
16
17
# File 'lib/span_view/parser.rb', line 13

def self.call(source)
  Span::Compiler.new.apply(Span::Grammar.new.parse(source))
rescue Parslet::ParseFailed => e
  raise ParseError, "Invalid .span template: #{deepest_failure_line(e)}"
end