Module: Tadpole::LocalTemplate

Defined in:
lib/tadpole/local_template.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



20
21
22
23
# File 'lib/tadpole/local_template.rb', line 20

def self.included(klass)
  klass.extend ClassMethods
  klass.extend Filters::ClassMethods
end

Instance Method Details

#T(extra_path, extra_opts = {}) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/tadpole/local_template.rb', line 25

def T(extra_path, extra_opts = {})
  opts = options.to_hash.update(extra_opts)
  dirname = File.dirname(caller.first[/^(.+?):/, 1])
  begin
    Template(path, extra_path).new(opts)
  rescue MissingTemplateError => e
    Tadpole.template_paths.each do |template_path|
      if dirname.index(template_path) == 0
        path = dirname[template_path.length..-1]
        return Template(path, extra_path).new(opts)
      end
    end
    raise e
  end
end