Usage

Most users will probably use Erubi via Rails or Tilt. Erubi is the default
erb template handler in Tilt 2.0.6+ and Rails 5.1+.

Capturing

Erubi does not support capturing block output into the template by default.
However, it comes with an erubi/capture_end file that supports
capturing via <%|= and <%|== tags which are
closed with a <%| tag:

<%|= form do %>
<input>
<%| end %>

This offers similar functionality to that offered by Rails'
<%= tags, but without the corner cases with that approach
(which are due to attempting to parse ruby code via a regexp). Similar to
the <%= and <%== tags, <%|=
captures by default and <%|== captures and escapes by
default, but this can be reversed via the :escape_capture or
:escape options.

When using the capture_end support, any methods (such as form
in the example above) should return the (potentially modified) buffer.
Since the buffer variable is a local variable and not an instance variable
by default, you'll probably want to set the :bufvar
variable when using the capture_end support to an instance variable, and
have any methods used access that instance variable. Example:

defform@_buf<<"<form>"yield@_buf<<"</form>"@_bufendputseval(Erubi::CaptureEndEngine.new(<<-END,:bufvar=>:@_buf).src)before
<%|= form do %>
inside
<%| end %>
after
END
# Output:
# before
# <form>
# inside
# </form>
# after

Alternatively, passing the option :yield_returns_buffer => true will
return the buffer captured by the block instead of the last expression in
the block.