Class: RBlade::ComponentStore
- Inherits:
-
Object
- Object
- RBlade::ComponentStore
- Defined in:
- lib/rblade/component_store.rb
Class Method Summary collapse
Class Method Details
.add_path(path, namespace = nil) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'lib/rblade/component_store.rb', line 28 def self.add_path path, namespace = nil path = path.to_s if !path.end_with? "/" path = path + "/" end @@templatePaths[namespace] ||= [] @@templatePaths[namespace] << path end |
.fetchComponent(name) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/rblade/component_store.rb', line 7 def self.fetchComponent name namespace = nil path = name if name.match '::' namespace, path = name.split('::') end path.gsub! '.', '/' @@templatePaths[namespace]&.each do |base_path| FILE_EXTENSIONS.each do |extension| if File.exist? base_path + path + extension return RBlade::Compiler.compileString File.read(base_path + path + extension) end end end raise StandardError.new "Unknown component #{name}" end |