Class: Tadpole::SectionProviders::TemplateProvider
- Inherits:
-
SectionProvider
- Object
- SectionProvider
- Tadpole::SectionProviders::TemplateProvider
- Defined in:
- lib/tadpole/providers/template.rb
Constant Summary collapse
- EXTENSIONS =
['']
Instance Attribute Summary
Attributes inherited from SectionProvider
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(full_path, owner) ⇒ TemplateProvider
constructor
A new instance of TemplateProvider.
- #render(locals = {}, &block) ⇒ Object
Methods inherited from SectionProvider
#inspect, #method_missing, provides?
Constructor Details
#initialize(full_path, owner) ⇒ TemplateProvider
Returns a new instance of TemplateProvider.
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.) 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
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 |