module Sinatra::Templates
def render_erb(template, data, options, locals, &block)
def render_erb(template, data, options, locals, &block) original_out_buf = defined?(@_out_buf) && @_out_buf data = data.call if data.kind_of? Proc instance = ::ERB.new(data, nil, nil, '@_out_buf') locals_assigns = locals.to_a.collect { |k,v| "#{k} = locals[:#{k}]" } filename = options.delete(:filename) || '(__ERB__)' line = options.delete(:line) || 1 line -= 1 if instance.src =~ /^#coding:/ render_binding = binding eval locals_assigns.join("\n"), render_binding eval instance.src, render_binding, filename, line @_out_buf, result = original_out_buf, @_out_buf result end