Module: SugarBee::Parser

Defined in:
lib/sugar_bee/parser.rb

Overview

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

Class Method Summary collapse

Class Method Details

.call(source) ⇒ Object



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

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