Class: Erubi::CaptureEndEngine
- Defined in:
- lib/erubi/capture_end.rb
Overview
An engine class that supports capturing blocks via the <%|=
and <%|==
tags, explicitly ending the captures using <%|
end %>
blocks.
Constant Summary
Constants inherited from Engine
Instance Attribute Summary
Attributes inherited from Engine
Instance Method Summary collapse
-
#initialize(input, properties = {}) ⇒ CaptureEndEngine
constructor
Initializes the engine.
Constructor Details
#initialize(input, properties = {}) ⇒ CaptureEndEngine
Initializes the engine. Accepts the same arguments as ::Erubi::Engine, and these additional options:
- :escape_capture
-
Whether to make
<%|=
escape by default, and<%|==
not escape by default, defaults to the same value as :escape. - :yield_returns_buffer
-
Whether to have
<%|
tags insert the buffer as an expression, so that<%| end %>
tags will have the buffer be the last expression inside the block, and therefore have the buffer be returned by the yield expression. Normally the buffer will be returned anyway, but there are cases where the last expression will not be the buffer, and therefore a different object will be returned.
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/erubi/capture_end.rb', line 19 def initialize(input, properties={}) properties = Hash[properties] escape = properties.fetch(:escape){properties.fetch(:escape_html, false)} @escape_capture = properties.fetch(:escape_capture, escape) @yield_returns_buffer = properties.fetch(:yield_returns_buffer, false) @bufval = properties[:bufval] ||= '::String.new' @bufstack = '__erubi_stack' properties[:regexp] ||= /<%(\|?={1,2}|-|\#|%|\|)?(.*?)([-=])?%>([ \t]*\r?\n)?/m super end |