Class: Tadpole::SectionProviders::TemplateProvider

Inherits:
SectionProvider show all
Defined in:
lib/tadpole/providers/template.rb

Constant Summary collapse

EXTENSIONS =
['']

Instance Attribute Summary

Attributes inherited from SectionProvider

#content, #full_path, #owner

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from SectionProvider

#inspect, #method_missing, provides?

Constructor Details

#initialize(full_path, owner) ⇒ TemplateProvider

Returns a new instance of TemplateProvider.

Raises:

  • (ArgumentError)


8
9
10
11
12
13
14
15
16
17
18
# File 'lib/tadpole/providers/template.rb', line 8

def initialize(full_path, owner)
  self.owner = owner
  self.full_path = full_path
  Tadpole.template_paths.each do |template_path|
    if full_path.index(template_path) == 0
      path = full_path[template_path.length..-1]
      @template = Tadpole(owner.path, path).new(owner.options)
    end
  end
  raise ArgumentError, "no template at `#{full_path}'" unless @template
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Tadpole::SectionProviders::SectionProvider

Class Method Details

.path_suitable?(full_path) ⇒ Boolean

Returns:

  • (Boolean)


6
# File 'lib/tadpole/providers/template.rb', line 6

def self.path_suitable?(full_path) File.directory?(full_path) end

Instance Method Details

#render(locals = {}, &block) ⇒ Object



20
21
22
# File 'lib/tadpole/providers/template.rb', line 20

def render(locals = {}, &block)
  @template.run(locals)
end