Class: Padrino::Helpers::OutputHelpers::SlimHandler
- Inherits:
-
AbstractHandler
- Object
- AbstractHandler
- Padrino::Helpers::OutputHelpers::SlimHandler
- Defined in:
- lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb
Overview
Handler for reading and writing from a slim template.
Instance Attribute Summary collapse
-
#output_buffer ⇒ Object
readonly
Returns the value of attribute output_buffer.
Attributes inherited from AbstractHandler
Instance Method Summary collapse
-
#block_is_type?(block) ⇒ Boolean
Returns true if the block given is of the handler’s template type; false otherwise.
-
#capture_from_template(*args, &block) ⇒ Object
Captures the html from a block of template code for this handler.
-
#concat_to_template(text = "") ⇒ Object
Outputs the given text to the templates buffer directly.
-
#engines ⇒ Object
Returns an array of engines used for the template.
-
#initialize(template) ⇒ SlimHandler
constructor
A new instance of SlimHandler.
-
#is_type? ⇒ Boolean
Returns true if the current template type is same as this handlers; false otherwise.
Methods inherited from AbstractHandler
Constructor Details
#initialize(template) ⇒ SlimHandler
Returns a new instance of SlimHandler.
12 13 14 15 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 12 def initialize(template) super @output_buffer = template.instance_variable_get(:@_out_buf) end |
Instance Attribute Details
#output_buffer ⇒ Object
Returns the value of attribute output_buffer.
10 11 12 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 10 def output_buffer @output_buffer end |
Instance Method Details
#block_is_type?(block) ⇒ Boolean
Returns true if the block given is of the handler’s template type; false otherwise.
57 58 59 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 57 def block_is_type?(block) is_type? || (block && eval('defined? __in_erb_template', block.binding)) end |
#capture_from_template(*args, &block) ⇒ Object
Captures the html from a block of template code for this handler
32 33 34 35 36 37 38 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 32 def capture_from_template(*args, &block) self.output_buffer, _buf_was = ActiveSupport::SafeBuffer.new, self.output_buffer captured_block = block.call(*args) ret = eval("@_out_buf", block.binding) self.output_buffer = _buf_was [ ret, captured_block ] end |
#concat_to_template(text = "") ⇒ Object
Outputs the given text to the templates buffer directly
46 47 48 49 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 46 def concat_to_template(text="") self.output_buffer << text if is_type? && text nil end |
#engines ⇒ Object
Returns an array of engines used for the template
67 68 69 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 67 def engines @_engines ||= [:slim] end |
#is_type? ⇒ Boolean
Returns true if the current template type is same as this handlers; false otherwise.
23 24 25 |
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/slim_handler.rb', line 23 def is_type? !self.output_buffer.nil? end |