% begin %> <% # redefine print, puts & p OUTPUT = StringIO.new def print *args OUTPUT.print *args end def puts *args OUTPUT.puts *args end def p *args OUTPUT.puts *args.map(&:inspect) end %> <% begin %> <% binding = Object.new.send :binding %> <% binding.eval(script, "(script)", 1) %> <% OUTPUT.string.each_line do |line| %>
<%= h line %>
<% end %> <% rescue => error %><%= h error.class %>: <%= h error.message %>
<% error.backtrace.each do |backtrace| %> <% next unless backtrace.start_with? "(script)" %><%= h backtrace %>
<% end %> <% end %> <% rescue => error %> <%= erb :error, locals: { error: error }, layout: false %> <% end %>