Class: Babl::AbsoluteLookupContext
- Inherits:
-
Object
- Object
- Babl::AbsoluteLookupContext
- Defined in:
- lib/babl.rb
Instance Attribute Summary collapse
-
#search_path ⇒ Object
readonly
Returns the value of attribute search_path.
Instance Method Summary collapse
- #find(current_template, partial_name) ⇒ Object
-
#initialize(search_path) ⇒ AbsoluteLookupContext
constructor
A new instance of AbsoluteLookupContext.
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_path ⇒ Object (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 58 |
# 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 |