mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
7da8d76206
Erubi offers the following advantages for Rails: * Works with ruby's --enable-frozen-string-literal option * Has 88% smaller memory footprint * Does no freedom patching (Erubis adds a method to Kernel) * Has simpler internals (1 file, <150 lines of code) * Has an open development model (Erubis doesn't have a public source control repository or bug tracker) * Is not dead (Erubis hasn't been updated since 2011) Erubi is a simplified fork of Erubis that contains just the parts that are generally needed (which includes the parts that Rails uses). The only intentional difference in behavior is that it does not include support for <%=== tags for debug output. That could be added to the ActionView ERB handler if it is desired. The Erubis template handler remains in a deprecated state so that code that accesses it directly does not break. It can be removed after Rails 5.1.
24 lines
688 B
Ruby
24 lines
688 B
Ruby
module ERBTest
|
|
class ViewContext
|
|
include ActionView::Helpers::UrlHelper
|
|
include SharedTestRoutes.url_helpers
|
|
include ActionView::Helpers::TagHelper
|
|
include ActionView::Helpers::JavaScriptHelper
|
|
include ActionView::Helpers::FormHelper
|
|
|
|
attr_accessor :output_buffer, :controller
|
|
|
|
def protect_against_forgery?() false end
|
|
end
|
|
|
|
class BlockTestCase < ActiveSupport::TestCase
|
|
def render_content(start, inside)
|
|
template = block_helper(start, inside)
|
|
ActionView::Template::Handlers::ERB.erb_implementation.new(template).evaluate(ViewContext.new)
|
|
end
|
|
|
|
def block_helper(str, rest)
|
|
"<%= #{str} do %>#{rest}<% end %>"
|
|
end
|
|
end
|
|
end
|