Class: Padrino::Helpers::OutputHelpers::AbstractHandler Abstract

Inherits:
Object
  • Object
show all
Defined in:
lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb

Overview

This class is abstract.

Extend this to create a template handler

Direct Known Subclasses

ErbHandler, HamlHandler, SlimHandler

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(template) ⇒ AbstractHandler

Returns a new instance of AbstractHandler.



30
31
32
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 30

def initialize(template)
  @template = template
end

Instance Attribute Details

#templateObject (readonly)

Returns the value of attribute template.



28
29
30
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 28

def template
  @template
end

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)


72
73
74
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 72

def block_is_type?(block)
  # Implemented in subclass
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..."


82
83
84
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 82

def capture_from_template(*args, &block)
  # Implemented in subclass
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")


92
93
94
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 92

def concat_to_template(text="")
  # Implemented in subclass
end

#enginesObject

Returns an array of engines used for the template

Examples:

@handler.engines => [:erb, :erubis]


52
53
54
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 52

def engines
  # Implemented in subclass
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)


62
63
64
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 62

def is_type?
  # Implemented in subclass
end

#template_extensionObject

Returns extension of the template

Examples:

@handler.template_extension => "erb"


40
41
42
43
44
# File 'lib/vendored-middleman-deps/padrino-helpers-0.11.2/lib/padrino-helpers/output_helpers/abstract_handler.rb', line 40

def template_extension
  caller.find { |c| c =~ /\/views\// }[/\.([\w]*?)\:/, 1] rescue nil
  # "/some/path/app/views/posts/foo.html.erb:3:in `evaluate_source'"
  # => "erb"
end