Class: Sinatra::ContentFor2::ErbHandler

Inherits:
BaseHandler show all
Defined in:
lib/sinatra/content_for2/erb_handler.rb

Instance Attribute Summary collapse

Attributes inherited from BaseHandler

#template

Instance Method Summary collapse

Methods inherited from BaseHandler

classes, register

Constructor Details

#initialize(template) ⇒ ErbHandler

Returns a new instance of ErbHandler.



4
5
6
7
# File 'lib/sinatra/content_for2/erb_handler.rb', line 4

def initialize(template)
  super
  @output_buffer = get_buf
end

Instance Attribute Details

#output_bufferObject

Returns the value of attribute output_buffer.



2
3
4
# File 'lib/sinatra/content_for2/erb_handler.rb', line 2

def output_buffer
  @output_buffer
end

Instance Method Details

#block_is_type?(block) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/sinatra/content_for2/erb_handler.rb', line 13

def block_is_type?(block)
  is_type? || (block && eval('defined?(__in_erb_template)', block.binding))
end

#capture_from_template(*args, &block) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/sinatra/content_for2/erb_handler.rb', line 21

def capture_from_template(*args, &block)
  self.output_buffer, _buf_was = '', self.output_buffer
  block.call(*args)
  ret = eval('@_out_buf || @_buf', block.binding)
  self.output_buffer = _buf_was
  ret
end

#enginesObject



17
18
19
# File 'lib/sinatra/content_for2/erb_handler.rb', line 17

def engines
  @engines ||= [ :erb, :erubis ]
end

#is_type?Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/sinatra/content_for2/erb_handler.rb', line 9

def is_type?
  ! self.output_buffer.nil?
end