Module: ViewComponentContrib::Preview::DefaultTemplate::ClassMethods
- Defined in:
- lib/view_component_contrib/preview/default_template.rb
Instance Attribute Summary collapse
Instance Method Summary collapse
Instance Attribute Details
#default_preview_template ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/view_component_contrib/preview/default_template.rb', line 27 def default_preview_template return @default_preview_template if defined?(@default_preview_template) @default_preview_template = if superclass.respond_to?(:default_preview_template) superclass.default_preview_template else DEFAULT_TEMPLATE end end |
Instance Method Details
#preview_example_template_path(example) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/view_component_contrib/preview/default_template.rb', line 38 def preview_example_template_path(example) super rescue MISSING_TEMPLATE_ERROR has_example_preview = preview_paths.find do |path| Dir.glob(File.join(path, preview_name, "previews", "#{example}.html.*")).any? end return File.join(preview_name, "previews", example) if has_example_preview has_root_preview = preview_paths.find do |path| Dir.glob(File.join(path, preview_name, "preview.html.*")).any? end return File.join(preview_name, "preview") if has_root_preview default_preview_template end |