Parent

Files

Padrino::Helpers::OutputHelpers::ErbHandler

Handler for reading and writing from an erb template.

Attributes

output_buffer[R]

Public Class Methods

new(template) click to toggle source
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 10
def initialize(template)
  super
  @output_buffer = template.instance_variable_get(:@_out_buf)
end

Public Instance Methods

block_is_type?(block) click to toggle source

Returns true if the block given is of the handler’s template type; false otherwise.

@example

@handler.block_is_type?(block) => true
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 55
def block_is_type?(block)
  is_type? || (block && eval('defined?(__in_erb_template)', block.binding))
end
capture_from_template(*args, &block) click to toggle source

Captures the html from a block of template code for this handler

@example

@handler.capture_from_template(&block) => "...html..."
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 30
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
concat_to_template(text="") click to toggle source

Outputs the given text to the templates buffer directly

@example

@handler.concat_to_template("This will be output to the template buffer")
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 44
def concat_to_template(text="")
  self.output_buffer << text if is_type? && text
  nil
end
engines() click to toggle source

Returns an array of engines used for the template

@example

@handler.engines => [:erb, :erubis]
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 65
def engines
  @_engines ||= [:erb, :erubis]
end
is_type?() click to toggle source

Returns true if the current template type is same as this handlers; false otherwise.

@example

@handler.is_type? => true
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 21
def is_type?
  !self.output_buffer.nil?
end

Protected Instance Methods

output_buffer=(val) click to toggle source
# File lib/padrino-helpers/output_helpers/erb_handler.rb, line 71
def output_buffer=(val)
  template.instance_variable_set(:@_out_buf, val)
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.