Module: RailsBlocks::Path
Constant Summary
collapse
- ELEMENT_FILE_PREFIX =
'__'
- MOD_FILE_PREFIX =
'_'
Class Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Names
#block_classes, #block_name, #element_classes, #element_name
Class Attribute Details
.tree ⇒ Object
12
13
14
15
16
17
18
|
# File 'lib/rails_blocks/path.rb', line 12
def self.tree
@tree ||= (
build_tree
)
end
|
Class Method Details
.blocks_dir ⇒ Object
20
21
22
|
# File 'lib/rails_blocks/path.rb', line 20
def self.blocks_dir
Rails.root.join RailsBlocks.config.blocks_dir
end
|
Instance Method Details
#block_template(b_name, options = {}) ⇒ Object
24
25
26
27
28
29
30
|
# File 'lib/rails_blocks/path.rb', line 24
def block_template(b_name, options = {})
options[:levels].reverse.each do |level|
next unless Path.tree[level][b_name]
return Path.tree[level][b_name][mod(options)] || Path.tree[level][b_name]['']
end
nil
end
|
#element_template(b_name, e_name, options = {}) ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'lib/rails_blocks/path.rb', line 32
def element_template(b_name, e_name, options = {})
options[:levels].reverse.each do |level|
next unless Path.tree[level][b_name]
next unless Path.tree[level][b_name][:elements][e_name]
return Path.tree[level][b_name][:elements][e_name][mod(options)] || Path.tree[level][b_name][:elements][e_name]['']
end
nil
end
|