Class: Benoit::Utils::FindsLayoutsForTemplate
- Inherits:
-
Object
- Object
- Benoit::Utils::FindsLayoutsForTemplate
- Defined in:
- lib/benoit/utils/finds_layouts_for_template.rb
Instance Attribute Summary collapse
-
#input ⇒ Object
readonly
Returns the value of attribute input.
-
#load_paths ⇒ Object
readonly
Returns the value of attribute load_paths.
-
#root ⇒ Object
readonly
Returns the value of attribute root.
-
#template_path ⇒ Object
readonly
Returns the value of attribute template_path.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(input, options) ⇒ FindsLayoutsForTemplate
constructor
A new instance of FindsLayoutsForTemplate.
- #lookup_layout ⇒ Object
- #lookup_layouts ⇒ Object
- #match_extends_line(content) ⇒ Object
Constructor Details
#initialize(input, options) ⇒ FindsLayoutsForTemplate
Returns a new instance of FindsLayoutsForTemplate.
25 26 27 28 29 30 31 32 33 34 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 25 def initialize(input, ) if input.respond_to? :path @input = input @template_path = input else @content = input end @load_paths = .delete(:load_paths) || [""] @root = .delete(:root) end |
Instance Attribute Details
#input ⇒ Object (readonly)
Returns the value of attribute input.
19 20 21 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 19 def input @input end |
#load_paths ⇒ Object (readonly)
Returns the value of attribute load_paths.
19 20 21 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 19 def load_paths @load_paths end |
#root ⇒ Object (readonly)
Returns the value of attribute root.
19 20 21 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 19 def root @root end |
#template_path ⇒ Object (readonly)
Returns the value of attribute template_path.
19 20 21 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 19 def template_path @template_path end |
Class Method Details
.first_layout(content, options = {}) ⇒ Object
21 22 23 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 21 def self.first_layout(content, ={}) FindsLayoutsForTemplate.new(content, ).lookup_layout end |
Instance Method Details
#lookup_layout ⇒ Object
43 44 45 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 43 def lookup_layout match_extends_line(@content) end |
#lookup_layouts ⇒ Object
47 48 49 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 47 def lookup_layouts recursively_lookup_layouts_for_file(input) end |
#match_extends_line(content) ⇒ Object
36 37 38 39 40 41 |
# File 'lib/benoit/utils/finds_layouts_for_template.rb', line 36 def match_extends_line(content) extends_pattern = /\{% extends "([\.\w-]+)" %\}/ match_data = content.match(extends_pattern) return unless match_data match_data.captures[0] end |