class ERB::Compiler
def compile(s)
Compiles an ERB template into Ruby code. Returns an array of the code
def compile(s) enc = s.encoding raise ArgumentError, "#{enc} is not ASCII compatible" if enc.dummy? s = s.b # see String#b magic_comment = detect_magic_comment(s, enc) out = Buffer.new(self, *magic_comment) self.content = +'' scanner = make_scanner(s) scanner.scan do |token| next if token.nil? next if token == '' if scanner.stag.nil? compile_stag(token, out, scanner) else compile_etag(token, out, scanner) end end add_put_cmd(out, content) if content.size > 0 out.close return out.script, *magic_comment end