Class: Sinatra::ContentFor2::ErbHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- Sinatra::ContentFor2::ErbHandler
- Defined in:
- lib/sinatra/content_for2/erb_handler.rb
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
readonly
Returns the value of attribute output_buffer.
Attributes inherited from BaseHandler
Instance Method Summary collapse
- #block_is_type?(block) ⇒ Boolean
- #capture_from_template(*args, &block) ⇒ Object
- #engines ⇒ Object
-
#initialize(template) ⇒ ErbHandler
constructor
A new instance of ErbHandler.
- #is_type? ⇒ Boolean
Methods inherited from BaseHandler
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_buffer ⇒ Object
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
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 |
#engines ⇒ Object
17 18 19 |
# File 'lib/sinatra/content_for2/erb_handler.rb', line 17 def engines @engines ||= [ :erb, :erubis ] end |
#is_type? ⇒ Boolean
9 10 11 |
# File 'lib/sinatra/content_for2/erb_handler.rb', line 9 def is_type? ! self.output_buffer.nil? end |