Class: Babl::AbsoluteLookupContext

Inherits:
Object
  • Object
show all
Defined in:
lib/babl.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_path) ⇒ AbsoluteLookupContext

Returns a new instance of AbsoluteLookupContext.



46
47
48
49
# File 'lib/babl.rb', line 46

def initialize(search_path)
    @search_path = search_path
    raise Errors::InvalidTemplate, 'Missing search path' unless search_path
end

Instance Attribute Details

#search_pathObject (readonly)

Returns the value of attribute search_path.



44
45
46
# File 'lib/babl.rb', line 44

def search_path
  @search_path
end

Instance Method Details

#find(current_template, partial_name) ⇒ Object



51
52
53
54
55
56
57
# File 'lib/babl.rb', line 51

def find(current_template, partial_name)
    query = File.join(search_path, "{#{partial_name}}{.babl,}")
    path = Dir[query].first
    return unless path
    source = File.read(path)
    [current_template.source(source, path, 0), self]
end