class Padrino::Helpers::OutputHelpers::ErbHandler
Handler for reading and writing from an erb template.
#
def block_is_type?(block)
@handler.block_is_type?(block) => true
@example
Returns true if the block given is of the handler's template type; false otherwise.
#
def block_is_type?(block) is_type? || (block && eval('defined?(__in_erb_template)', block.binding)) end
def capture_from_template(*args, &block)
@handler.capture_from_template(&block) => "...html..."
@example
Captures the html from a block of template code for this handler
def capture_from_template(*args, &block) self.output_buffer, _buf_was = "", self.output_buffer block.call(*args) ret = eval("@_out_buf", block.binding) self.output_buffer = _buf_was ret end
def concat_to_template(text="")
@handler.concat_to_template("This will be output to the template buffer")
@example
Outputs the given text to the templates buffer directly
#
def concat_to_template(text="") self.output_buffer << text if is_type? && text nil end
def engines
@handler.engines => [:erb, :erubis]
@example
Returns an array of engines used for the template
#
def engines @_engines ||= [:erb, :erubis] end
def initialize(template)
def initialize(template) super @output_buffer = template.instance_variable_get(:@_out_buf) end
def is_type?
@handler.is_type? => true
@example
Returns true if the current template type is same as this handlers; false otherwise.
#
def is_type? !self.output_buffer.nil? end
def output_buffer=(val)
def output_buffer=(val) template.instance_variable_set(:@_out_buf, val) end