Class: Rbexy::Rails::ComponentTemplateResolver
- Inherits:
-
ActionView::FileSystemResolver
- Object
- ActionView::FileSystemResolver
- Rbexy::Rails::ComponentTemplateResolver
- Defined in:
- lib/rbexy/rails/component_template_resolver.rb
Instance Method Summary collapse
-
#_find_all(name, prefix, partial, details, key, locals) ⇒ Object
Rails 6 requires us to override ‘_find_all` in order to hook.
-
#find_templates(name, prefix, partial, details, locals = []) ⇒ Object
Rails 5 only requires ‘find_templates` (which tbh is the proper way to implement subclasses of ActionView::Resolver).
Instance Method Details
#_find_all(name, prefix, partial, details, key, locals) ⇒ Object
Rails 6 requires us to override ‘_find_all` in order to hook
7 8 9 |
# File 'lib/rbexy/rails/component_template_resolver.rb', line 7 def _find_all(name, prefix, partial, details, key, locals) find_templates(name, prefix, partial, details, locals) end |
#find_templates(name, prefix, partial, details, locals = []) ⇒ Object
Rails 5 only requires ‘find_templates` (which tbh is the proper way to implement subclasses of ActionView::Resolver)
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rbexy/rails/component_template_resolver.rb', line 13 def find_templates(name, prefix, partial, details, locals = []) return [] unless name.is_a? Rbexy::Component::TemplatePath templates_path = File.join(@path, prefix, name) extensions = details[:handlers].join(",") Dir["#{templates_path}.*{#{extensions}}"].map do |template_path| source = File.binread(template_path) handler = ActionView::Template.handler_for_extension(File.extname(template_path)[1..-1]) virtual_path = ["rbexy_component", prefix, name].join("/") ActionView::Template.new( source, template_path, handler, locals: [], virtual_path: virtual_path ) end end |