Module: RailsBlocks::Path

Includes:
Names
Included in:
BlockHelper
Defined in:
lib/rails_blocks/path.rb

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

.treeObject



12
13
14
15
16
# File 'lib/rails_blocks/path.rb', line 12

def self.tree
	@tree ||= (
		build_tree
	)
end

Class Method Details

.blocks_dirObject



22
23
24
# File 'lib/rails_blocks/path.rb', line 22

def self.blocks_dir
	Rails.root.join RailsBlocks.config.blocks_dir
end

.reload_treeObject



18
19
20
# File 'lib/rails_blocks/path.rb', line 18

def self.reload_tree
	@tree = build_tree
end

Instance Method Details

#block_template(b_name, options = {}) ⇒ Object



26
27
28
29
30
31
32
# File 'lib/rails_blocks/path.rb', line 26

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



34
35
36
37
38
39
40
41
# File 'lib/rails_blocks/path.rb', line 34

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