Class: Erubi::CaptureBlockEngine

Inherits:
Engine
  • Object
show all
Defined in:
lib/erubi/capture_block.rb

Overview

An engine class that supports capturing blocks via the <%= and <%== tags:

<%= upcase_form do %>
  <%= 'foo' %>
<% end %>

Where upcase_form is defined like:

def upcase_form(&block)
  "<form>#{@bufvar.capture(&block).upcase}</form>"
end

With output being:

<form>
  FOO
</form>

This requires using a string subclass as the buffer value, provided by the CaptureBlockEngine::Buffer class.

This engine does not support the :escapefunc option. To change the escaping function, use a subclass of CaptureBlockEngine::Buffer and override the #| method.

This engine does not support the :chain_appends option, and ignores it if present.

Defined Under Namespace

Classes: Buffer

Constant Summary

Constants inherited from Engine

Engine::DEFAULT_REGEXP

Instance Attribute Summary

Attributes inherited from Engine

#bufvar, #filename, #src

Instance Method Summary collapse

Constructor Details

#initialize(input, properties = {}) ⇒ CaptureBlockEngine

Returns a new instance of CaptureBlockEngine.



69
70
71
72
73
74
# File 'lib/erubi/capture_block.rb', line 69

def initialize(input, properties={})
  properties = Hash[properties]
  properties[:bufval] ||= '::Erubi::CaptureBlockEngine::Buffer.new'
  properties[:chain_appends] = false
  super
end