Class: Padrino::Helpers::OutputHelpers::HamlHandler

Inherits:
AbstractHandler show all
Defined in:
lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb

Overview

Handler for reading and writing from a haml template.

Instance Attribute Summary

Attributes inherited from AbstractHandler

#template

Instance Method Summary collapse

Methods inherited from AbstractHandler

#initialize, #template_extension

Constructor Details

This class inherits a constructor from Padrino::Helpers::OutputHelpers::AbstractHandler

Instance Method Details

#block_is_type?(block) ⇒ Boolean

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

Examples:

@handler.block_is_type?(block) => true

Returns:

  • (Boolean)


24
25
26
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb', line 24

def block_is_type?(block)
  template.block_is_haml?(block)
end

#capture_from_template(*args, &block) ⇒ Object

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

Examples:

@handler.capture_from_template(&block) => "...html..."


33
34
35
36
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb', line 33

def capture_from_template(*args, &block)
  eval("_hamlout ||= @haml_buffer", block.binding) # this is for rbx
  template.capture_haml(*args, &block)
end

#concat_to_template(text = "") ⇒ Object

Outputs the given text to the templates buffer directly

Examples:

@handler.concat_to_template("This will be output to the template buffer")


44
45
46
47
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb', line 44

def concat_to_template(text="")
  template.haml_concat(text)
  nil
end

#enginesObject

Returns an array of engines used for the template

Examples:

@handler.engines => [:haml]


55
56
57
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb', line 55

def engines
  @_engines ||= [:haml]
end

#is_type?Boolean

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

Examples:

@handler.is_type? => true

Returns:

  • (Boolean)


14
15
16
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/haml_handler.rb', line 14

def is_type?
  template.respond_to?(:is_haml?) && template.is_haml?
end