<% begin %> <% irb = IRB::Irb.new nil, StringInputMethod.new(script + "\nexit\n") %> <% IRB.conf[:MAIN_CONTEXT] = irb.context %> <% IRB.conf[:OUTPUT] = [] %> <% begin %> <% irb.eval_input %> <% IRB.Output.each do |key, line| %> <% case key when :stdin %>

<%= h line %>

<% when :stdout %>

<%= h line %>

<% when :stderr %>

<%= h line %>

<% end %> <% end %> <% rescue => error %>

<%= h error.class %>: <%= h error.message %>

<% error.backtrace.each do |backtrace| %>

<%= h backtrace %>

<% end %> <% end %> <% rescue => error %> <%= erb :error, locals: { error: error }, layout: false %> <% end %>